@credal/actions 0.2.141 → 0.2.143

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.
@@ -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, 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";
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";
2
2
  export const ACTION_GROUPS = {
3
3
  GENERIC: {
4
4
  description: "Generic utility actions",
@@ -47,7 +47,6 @@ export const ACTION_GROUPS = {
47
47
  googleOauthUpdatePresentationDefinition,
48
48
  googleOauthSearchDriveByKeywordsDefinition,
49
49
  googleOauthSearchDriveByQueryDefinition,
50
- googleOauthSearchDriveByQueryAndGetFileContentDefinition,
51
50
  googleOauthGetDriveFileContentByIdDefinition,
52
51
  ],
53
52
  },
@@ -199,8 +198,6 @@ export const ACTION_GROUPS = {
199
198
  githubCreateBranchDefinition,
200
199
  githubCreatePullRequestDefinition,
201
200
  githubListPullRequestsDefinition,
202
- githubGetFileContentDefinition,
203
- githubListDirectoryDefinition,
204
201
  ],
205
202
  },
206
203
  ASHBY: {
@@ -248,14 +245,4 @@ export const ACTION_GROUPS = {
248
245
  oktaTriggerOktaWorkflowDefinition,
249
246
  ],
250
247
  },
251
- LINEAR: {
252
- description: "Actions for interacting with Linear",
253
- actions: [
254
- linearGetIssueDetailsDefinition,
255
- linearGetProjectsDefinition,
256
- linearGetProjectDetailsDefinition,
257
- linearGetTeamDetailsDefinition,
258
- linearGetTeamsDefinition,
259
- ],
260
- },
261
248
  };
@@ -10,6 +10,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
11
11
  import searchDriveByQuery from "./searchDriveByQuery.js";
12
12
  import getDriveFileContentById from "./getDriveFileContentById.js";
13
+ // Helper function to process files in batches with concurrency control
14
+ const processBatch = (items_1, processor_1, ...args_1) => __awaiter(void 0, [items_1, processor_1, ...args_1], void 0, function* (items, processor, batchSize = 3) {
15
+ const results = [];
16
+ for (let i = 0; i < items.length; i += batchSize) {
17
+ const batch = items.slice(i, i + batchSize);
18
+ const batchResults = yield Promise.allSettled(batch.map(processor));
19
+ for (const result of batchResults) {
20
+ if (result.status === "fulfilled") {
21
+ results.push(result.value);
22
+ }
23
+ }
24
+ }
25
+ return results;
26
+ });
13
27
  const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
28
  var _b;
15
29
  if (!authParams.authToken) {
@@ -29,13 +43,33 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
29
43
  if (!searchResult.success) {
30
44
  return { success: false, error: searchResult.error };
31
45
  }
32
- // For each file, fetch its content in parallel
33
46
  const files = (_b = searchResult.files) !== null && _b !== void 0 ? _b : [];
34
- const contentPromises = files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
47
+ // File types that are likely to fail or have no useful text content
48
+ const problematicMimeTypes = new Set([
49
+ "application/vnd.google-apps.form",
50
+ "application/vnd.google-apps.site",
51
+ "application/vnd.google-apps.map",
52
+ "application/vnd.google-apps.drawing",
53
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation", // PowerPoint
54
+ "application/vnd.ms-powerpoint",
55
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // Excel (not supported yet)
56
+ "application/vnd.ms-excel",
57
+ ]);
58
+ // Filter out problematic files BEFORE processing to avoid wasting resources
59
+ const validFiles = files
60
+ .slice(0, limit)
61
+ .filter(file => file.id && file.name && !problematicMimeTypes.has(file.mimeType));
62
+ // Process only valid files in smaller batches to avoid overwhelming the API
63
+ const filesWithContent = yield processBatch(validFiles, (file) => __awaiter(void 0, void 0, void 0, function* () {
35
64
  var _a, _b, _c;
36
65
  try {
66
+ // Add timeout for individual file content requests with shorter timeout
37
67
  const contentResult = yield getDriveFileContentById({
38
- params: { fileId: file.id, limit: maxChars },
68
+ params: {
69
+ fileId: file.id,
70
+ limit: maxChars,
71
+ timeoutLimit: 2,
72
+ },
39
73
  authParams,
40
74
  });
41
75
  return {
@@ -46,17 +80,16 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
46
80
  content: contentResult.success ? (_c = (_b = (_a = contentResult.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.contents) === null || _c === void 0 ? void 0 : _c.content : undefined,
47
81
  };
48
82
  }
49
- catch (error) {
50
- console.error(`Error fetching content for file ${file.id}:`, error);
83
+ catch (_d) {
51
84
  return {
52
85
  id: file.id,
53
86
  name: file.name,
54
87
  mimeType: file.mimeType,
55
88
  url: file.url,
89
+ content: undefined, // Gracefully handle errors
56
90
  };
57
91
  }
58
- }));
59
- const filesWithContent = yield Promise.all(contentPromises);
92
+ }), 5);
60
93
  // Return combined results
61
94
  return {
62
95
  success: true,
@@ -37,14 +37,14 @@ const searchDriveByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({
37
37
  });
38
38
  // Original search method - search all drives at once
39
39
  const searchAllDrivesAtOnce = (query, authToken, limit, orderByQuery) => __awaiter(void 0, void 0, void 0, function* () {
40
- const allDrivesUrl = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=allDrives&pageSize=1000${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
40
+ const allDrivesUrl = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=allDrives&pageSize=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
41
41
  const allDrivesRes = axiosClient.get(allDrivesUrl, {
42
42
  headers: {
43
43
  Authorization: `Bearer ${authToken}`,
44
44
  },
45
45
  });
46
46
  // need to search domain wide separately because the allDrives search doesn't include domain wide files
47
- const orgWideUrl = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&corpora=domain&pageSize=1000${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
47
+ const orgWideUrl = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&corpora=domain&pageSize=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
48
48
  const orgWideRes = axiosClient.get(orgWideUrl, {
49
49
  headers: {
50
50
  Authorization: `Bearer ${authToken}`,
@@ -76,7 +76,7 @@ const searchAllDrivesIndividually = (query, authToken, limit, orderByQuery) => _
76
76
  `q=${encodeURIComponent(query)}&` +
77
77
  `fields=files(id,name,mimeType,webViewLink),nextPageToken&` +
78
78
  `corpora=domain&` +
79
- `pageSize=1000${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
79
+ `pageSize=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}`;
80
80
  const domainDriveFunction = () => __awaiter(void 0, void 0, void 0, function* () {
81
81
  var _a, _b;
82
82
  const domainRes = yield axiosClient.get(domainUrl, {
@@ -148,11 +148,11 @@ const searchSingleDrive = (query, driveId, authToken, orderByQuery) => __awaiter
148
148
  let url;
149
149
  if (driveId === "root") {
150
150
  // Search in user's personal drive
151
- url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink),nextPageToken&pageSize=1000${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}${nextPageToken ? `&pageToken=${nextPageToken}` : ""}`;
151
+ url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink),nextPageToken&pageSize=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}${nextPageToken ? `&pageToken=${nextPageToken}` : ""}`;
152
152
  }
153
153
  else {
154
154
  // Search in specific shared drive
155
- url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(`${query} and parents in '${driveId}'`)}&fields=files(id,name,mimeType,webViewLink),nextPageToken&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=drive&driveId=${driveId}&pageSize=1000${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}${nextPageToken ? `&pageToken=${nextPageToken}` : ""}`;
155
+ url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(`${query} and parents in '${driveId}'`)}&fields=files(id,name,mimeType,webViewLink),nextPageToken&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=drive&driveId=${driveId}&pageSize=100${orderByQuery ? `&orderBy=${encodeURIComponent(orderByQuery)}` : ""}${nextPageToken ? `&pageToken=${nextPageToken}` : ""}`;
156
156
  }
157
157
  const res = yield axiosClient.get(url, {
158
158
  headers: {
@@ -0,0 +1,3 @@
1
+ import { salesforceGetSalesforceRecordsByQueryFunction } from "../../autogen/types";
2
+ declare const getSalesforceRecordByQuery: salesforceGetSalesforceRecordsByQueryFunction;
3
+ export default getSalesforceRecordByQuery;
@@ -0,0 +1,43 @@
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
+ const getSalesforceRecordByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ const { authToken, baseUrl } = authParams;
15
+ const { query, limit } = params;
16
+ if (!authToken || !baseUrl) {
17
+ return {
18
+ success: false,
19
+ error: "authToken and baseUrl are required for Salesforce API",
20
+ };
21
+ }
22
+ // The API limits the maximum number of records returned to 2000, the limit lets the user set a smaller custom limit
23
+ const url = `${baseUrl}/services/data/v56.0/query/?q=${encodeURIComponent(query + " LIMIT " + (limit != undefined && limit <= 2000 ? limit : 2000))}`;
24
+ try {
25
+ const response = yield axiosClient_1.axiosClient.get(url, {
26
+ headers: {
27
+ Authorization: `Bearer ${authToken}`,
28
+ },
29
+ });
30
+ return {
31
+ success: true,
32
+ records: response.data,
33
+ };
34
+ }
35
+ catch (error) {
36
+ console.error("Error retrieving Salesforce record:", error);
37
+ return {
38
+ success: false,
39
+ error: error instanceof Error ? error.message : "An unknown error occurred",
40
+ };
41
+ }
42
+ });
43
+ exports.default = getSalesforceRecordByQuery;
@@ -47,11 +47,22 @@ const getSalesforceRecordsByQuery = (_a) => __awaiter(void 0, [_a], void 0, func
47
47
  success: true,
48
48
  results:
49
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
- recordsWithUrl.map((record) => ({
51
- name: record.Name,
52
- url: record.webUrl,
53
- content: record,
54
- })) || [],
50
+ recordsWithUrl.map((record) => {
51
+ // Try common name fields in order of preference, using only what's available
52
+ const displayName = record.Name ||
53
+ record.Title ||
54
+ record.Subject ||
55
+ record.CaseNumber ||
56
+ record.AccountName ||
57
+ record.ContactName ||
58
+ record.Id ||
59
+ record.webUrl;
60
+ return {
61
+ name: displayName,
62
+ url: record.webUrl,
63
+ content: record,
64
+ };
65
+ }) || [],
55
66
  };
56
67
  }
57
68
  catch (error) {
@@ -47,7 +47,16 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
47
47
  results: response.data.searchRecords.map((record) => {
48
48
  const recordId = record.Id;
49
49
  const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
50
- return { name: record.Name, url: webUrl, contents: record };
50
+ // Try common name fields in order of preference, using only what's available
51
+ const displayName = record.Name ||
52
+ record.Title ||
53
+ record.Subject ||
54
+ record.CaseNumber ||
55
+ record.AccountName ||
56
+ record.ContactName ||
57
+ record.Id ||
58
+ webUrl;
59
+ return { name: displayName, url: webUrl, contents: record };
51
60
  }),
52
61
  };
53
62
  }
@@ -9,21 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { WebClient } from "@slack/web-api";
11
11
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
- import { getSlackChannels } from "./helpers.js";
13
12
  const archiveChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
13
  if (!authParams.authToken) {
15
14
  throw new Error(MISSING_AUTH_TOKEN);
16
15
  }
17
16
  try {
18
17
  const client = new WebClient(authParams.authToken);
19
- const { channelName } = params;
20
- const allChannels = yield getSlackChannels(client);
21
- const channel = allChannels.find(channel => channel.name == channelName);
22
- if (!channel || !channel.id) {
23
- throw Error(`Channel with name ${channelName} not found`);
24
- }
25
- yield client.conversations.join({ channel: channel.id });
26
- const result = yield client.conversations.archive({ channel: channel.id });
18
+ const { channelId } = params;
19
+ const result = yield client.conversations.archive({ channel: channelId });
27
20
  if (!result.ok) {
28
21
  return {
29
22
  success: false,
@@ -263,45 +263,70 @@ export function getGoogleDocContent(fileId, authToken, axiosClient, sharedDriveP
263
263
  }
264
264
  else {
265
265
  console.log("Error using Google Docs API", docsError);
266
- // Fallback to Drive API export if Docs API fails
267
- const exportUrl = `${GDRIVE_BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
268
- const exportRes = yield axiosClient.get(exportUrl, {
269
- headers: { Authorization: `Bearer ${authToken}` },
270
- responseType: "text",
271
- });
272
- return exportRes.data;
266
+ // Check if it's a 404 or permission error - don't retry these
267
+ if (docsError && typeof docsError === "object" && "status" in docsError) {
268
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
+ const status = docsError.status;
270
+ if (status === 404 || status === 403) {
271
+ throw new Error(`File not accessible (${status}): ${fileId}`);
272
+ }
273
+ }
274
+ try {
275
+ // Fallback to Drive API export if Docs API fails
276
+ const exportUrl = `${GDRIVE_BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
277
+ const exportRes = yield axiosClient.get(exportUrl, {
278
+ headers: { Authorization: `Bearer ${authToken}` },
279
+ responseType: "text",
280
+ });
281
+ return exportRes.data;
282
+ }
283
+ catch (_a) {
284
+ throw new Error(`Unable to access document content: ${fileId}`);
285
+ }
273
286
  }
274
287
  }
275
288
  });
276
289
  }
277
290
  export function getGoogleSheetContent(fileId, authToken, axiosClient, sharedDriveParams) {
278
291
  return __awaiter(this, void 0, void 0, function* () {
292
+ // Use CSV export as primary method - it's much faster and more reliable for large sheets
293
+ // The Sheets API with includeGridData can timeout on large spreadsheets
279
294
  try {
280
- const sheetsUrl = `https://sheets.googleapis.com/v4/spreadsheets/${fileId}?includeGridData=true`;
281
- const sheetsRes = yield axiosClient.get(sheetsUrl, {
282
- headers: {
283
- Authorization: `Bearer ${authToken}`,
284
- },
295
+ const exportUrl = `${GDRIVE_BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/csv${sharedDriveParams}`;
296
+ const exportRes = yield axiosClient.get(exportUrl, {
297
+ headers: { Authorization: `Bearer ${authToken}` },
298
+ responseType: "text",
285
299
  });
286
- return parseGoogleSheetsFromRawContentToPlainText(sheetsRes.data);
300
+ return exportRes.data
301
+ .split("\n")
302
+ .map((line) => line.replace(/,+$/, ""))
303
+ .map((line) => line.replace(/,{2,}/g, ","))
304
+ .join("\n");
287
305
  }
288
- catch (sheetsError) {
289
- if (isAxiosTimeoutError(sheetsError)) {
290
- console.log("Request timed out using Google Sheets API - dont retry");
291
- throw new Error("Request timed out using Google Sheets API");
306
+ catch (exportError) {
307
+ // Check if it's a 404 or permission error
308
+ if (exportError && typeof exportError === "object" && "status" in exportError) {
309
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
310
+ const status = exportError.status;
311
+ if (status === 404 || status === 403) {
312
+ throw new Error(`Spreadsheet not accessible (${status}): ${fileId}`);
313
+ }
292
314
  }
293
- else {
294
- console.log("Error using Google Sheets API", sheetsError);
295
- const exportUrl = `${GDRIVE_BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/csv${sharedDriveParams}`;
296
- const exportRes = yield axiosClient.get(exportUrl, {
297
- headers: { Authorization: `Bearer ${authToken}` },
298
- responseType: "text",
315
+ // If CSV export fails, try the Sheets API as fallback (but this is slower)
316
+ try {
317
+ const sheetsUrl = `https://sheets.googleapis.com/v4/spreadsheets/${fileId}?includeGridData=true`;
318
+ const sheetsRes = yield axiosClient.get(sheetsUrl, {
319
+ headers: {
320
+ Authorization: `Bearer ${authToken}`,
321
+ },
299
322
  });
300
- return exportRes.data
301
- .split("\n")
302
- .map((line) => line.replace(/,+$/, ""))
303
- .map((line) => line.replace(/,{2,}/g, ","))
304
- .join("\n");
323
+ return parseGoogleSheetsFromRawContentToPlainText(sheetsRes.data);
324
+ }
325
+ catch (sheetsError) {
326
+ if (isAxiosTimeoutError(sheetsError)) {
327
+ throw new Error("Request timed out using Google Sheets API");
328
+ }
329
+ throw new Error(`Unable to access spreadsheet content: ${fileId}`);
305
330
  }
306
331
  }
307
332
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.141",
3
+ "version": "0.2.143",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,
@@ -1,3 +0,0 @@
1
- import { confluenceUpdatePageFunction } from "../../../actions/autogen/types";
2
- declare const confluenceUpdatePage: confluenceUpdatePageFunction;
3
- export default confluenceUpdatePage;
@@ -1,47 +0,0 @@
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
- function getConfluenceApi(baseUrl, username, apiToken) {
17
- const api = axios_1.default.create({
18
- baseURL: baseUrl,
19
- headers: {
20
- Accept: "application/json",
21
- // Tokens are associated with a specific user.
22
- Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
23
- },
24
- });
25
- return api;
26
- }
27
- const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
28
- const { pageId, username, content, title } = params;
29
- const { baseUrl, authToken } = authParams;
30
- const api = getConfluenceApi(baseUrl, username, authToken);
31
- // Get current version number
32
- const response = yield api.get(`/api/v2/pages/${pageId}`);
33
- const currVersion = response.data.version.number;
34
- yield api.put(`/api/v2/pages/${pageId}`, {
35
- id: pageId,
36
- status: "current",
37
- title,
38
- body: {
39
- representation: "storage",
40
- value: content,
41
- },
42
- version: {
43
- number: currVersion + 1,
44
- },
45
- });
46
- });
47
- exports.default = confluenceUpdatePage;
@@ -1,8 +0,0 @@
1
- import { z } from "zod";
2
- export declare const TokenResponseSchema: z.ZodObject<{
3
- token: z.ZodString;
4
- }, "strip", z.ZodTypeAny, {
5
- token: string;
6
- }, {
7
- token: string;
8
- }>;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenResponseSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.TokenResponseSchema = zod_1.z.object({
6
- token: zod_1.z.string(),
7
- });