@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.
Files changed (175) hide show
  1. package/dist/actions/actionMapper.js +8 -1
  2. package/dist/actions/autogen/templates.d.ts +1 -0
  3. package/dist/actions/autogen/templates.js +79 -18
  4. package/dist/actions/autogen/types.d.ts +39 -0
  5. package/dist/actions/autogen/types.js +43 -8
  6. package/dist/actions/groups.js +4 -1
  7. package/dist/actions/invoke.js +11 -22
  8. package/dist/actions/parse.js +231 -244
  9. package/dist/actions/providers/asana/commentAsanaTask.js +8 -15
  10. package/dist/actions/providers/asana/createAsanaTask.js +20 -21
  11. package/dist/actions/providers/asana/getTasksDetails.js +18 -34
  12. package/dist/actions/providers/asana/listAsanaTasksByProject.js +62 -79
  13. package/dist/actions/providers/asana/searchAsanaTasks.js +6 -16
  14. package/dist/actions/providers/asana/updateAsanaTask.js +16 -15
  15. package/dist/actions/providers/asana/utils.js +47 -64
  16. package/dist/actions/providers/bing/getTopNSearchResultUrls.js +4 -14
  17. package/dist/actions/providers/confluence/fetchPageContent.js +5 -15
  18. package/dist/actions/providers/confluence/overwritePage.js +5 -14
  19. package/dist/actions/providers/finnhub/getBasicFinancials.js +7 -19
  20. package/dist/actions/providers/finnhub/symbolLookup.js +3 -12
  21. package/dist/actions/providers/firecrawl/deepResearch.js +11 -21
  22. package/dist/actions/providers/firecrawl/getTopNSearchResultUrls.js +8 -21
  23. package/dist/actions/providers/firecrawl/scrapeTweetDataWithNitter.js +4 -13
  24. package/dist/actions/providers/firecrawl/scrapeUrl.js +16 -21
  25. package/dist/actions/providers/firecrawl/searchAndScrape.js +6 -17
  26. package/dist/actions/providers/generic/fillTemplate.js +2 -11
  27. package/dist/actions/providers/github/createBranch.js +9 -18
  28. package/dist/actions/providers/github/createOrUpdateFile.js +6 -15
  29. package/dist/actions/providers/github/createPullRequest.js +5 -14
  30. package/dist/actions/providers/github/fetchFile.d.ts +3 -0
  31. package/dist/actions/providers/github/fetchFile.js +131 -0
  32. package/dist/actions/providers/github/getBranch.js +4 -13
  33. package/dist/actions/providers/github/getContents.d.ts +3 -0
  34. package/dist/actions/providers/github/getContents.js +41 -0
  35. package/dist/actions/providers/github/getFileContent.js +6 -16
  36. package/dist/actions/providers/github/getPullRequestDetails.js +39 -18
  37. package/dist/actions/providers/github/listCommits.js +17 -15
  38. package/dist/actions/providers/github/listDirectory.js +13 -25
  39. package/dist/actions/providers/github/listPullRequests.js +4 -13
  40. package/dist/actions/providers/github/searchOrganization.js +29 -49
  41. package/dist/actions/providers/github/utils.js +5 -16
  42. package/dist/actions/providers/gitlab/getFileContent.js +13 -24
  43. package/dist/actions/providers/gitlab/getMergeRequest.js +18 -30
  44. package/dist/actions/providers/gitlab/listDirectory.js +15 -27
  45. package/dist/actions/providers/gitlab/searchGroup.js +45 -52
  46. package/dist/actions/providers/gitlab/utils.js +19 -32
  47. package/dist/actions/providers/google-oauth/addGroupMember.js +3 -12
  48. package/dist/actions/providers/google-oauth/addTextToTopOfDoc.js +3 -12
  49. package/dist/actions/providers/google-oauth/appendRowsToSpreadsheet.js +4 -13
  50. package/dist/actions/providers/google-oauth/createNewGoogleDoc.js +7 -17
  51. package/dist/actions/providers/google-oauth/createPresentation.js +7 -13
  52. package/dist/actions/providers/google-oauth/createSpreadsheet.js +7 -13
  53. package/dist/actions/providers/google-oauth/deleteCalendarEvent.js +3 -12
  54. package/dist/actions/providers/google-oauth/deleteGroupMember.js +3 -12
  55. package/dist/actions/providers/google-oauth/deleteRowFromSpreadsheet.js +3 -12
  56. package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.js +4 -14
  57. package/dist/actions/providers/google-oauth/getDriveFileContentById.js +23 -33
  58. package/dist/actions/providers/google-oauth/getGroup.js +3 -12
  59. package/dist/actions/providers/google-oauth/getPresentation.js +23 -37
  60. package/dist/actions/providers/google-oauth/hasGroupMember.js +3 -12
  61. package/dist/actions/providers/google-oauth/listCalendarEvents.js +27 -21
  62. package/dist/actions/providers/google-oauth/listCalendars.js +4 -14
  63. package/dist/actions/providers/google-oauth/listGroupMembers.js +4 -13
  64. package/dist/actions/providers/google-oauth/listGroups.js +4 -14
  65. package/dist/actions/providers/google-oauth/queryGoogleBigQuery.js +10 -21
  66. package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +11 -14
  67. package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +3 -12
  68. package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +12 -23
  69. package/dist/actions/providers/google-oauth/searchDriveByQuery.js +30 -42
  70. package/dist/actions/providers/google-oauth/searchDriveByQueryAndGetFileContent.js +9 -20
  71. package/dist/actions/providers/google-oauth/updateCalendarEvent.js +3 -12
  72. package/dist/actions/providers/google-oauth/updateDoc.js +3 -12
  73. package/dist/actions/providers/google-oauth/updatePresentation.js +3 -12
  74. package/dist/actions/providers/google-oauth/updateRowsInSpreadsheet.js +4 -13
  75. package/dist/actions/providers/google-oauth/updateSpreadsheet.js +3 -12
  76. package/dist/actions/providers/google-oauth/utils/decodeMessage.js +7 -8
  77. package/dist/actions/providers/googleSearch/customSearch.js +18 -36
  78. package/dist/actions/providers/googlemail/listGmailThreads.js +7 -16
  79. package/dist/actions/providers/googlemail/replyToGmail.d.ts +3 -0
  80. package/dist/actions/providers/googlemail/replyToGmail.js +89 -0
  81. package/dist/actions/providers/googlemail/searchGmailMessages.js +10 -20
  82. package/dist/actions/providers/googlemail/sendGmail.js +7 -17
  83. package/dist/actions/providers/googlemaps/nearbysearchRestaurants.js +13 -25
  84. package/dist/actions/providers/googlemaps/validateAddress.js +3 -12
  85. package/dist/actions/providers/hubspot/getCompanies.js +4 -14
  86. package/dist/actions/providers/hubspot/getCompanyDetails.js +3 -12
  87. package/dist/actions/providers/hubspot/getContactDetails.js +3 -12
  88. package/dist/actions/providers/hubspot/getContacts.js +4 -14
  89. package/dist/actions/providers/hubspot/getDealDetails.js +3 -12
  90. package/dist/actions/providers/hubspot/getDeals.js +3 -12
  91. package/dist/actions/providers/hubspot/getTicketDetails.js +3 -12
  92. package/dist/actions/providers/hubspot/getTickets.js +3 -12
  93. package/dist/actions/providers/jira/assignJiraTicket.js +4 -13
  94. package/dist/actions/providers/jira/commentJiraTicket.js +3 -12
  95. package/dist/actions/providers/jira/createJiraTicket.js +22 -18
  96. package/dist/actions/providers/jira/createServiceDeskRequest.js +3 -12
  97. package/dist/actions/providers/jira/getJiraDCIssuesByQuery.js +5 -14
  98. package/dist/actions/providers/jira/getJiraIssuesByQuery.js +19 -29
  99. package/dist/actions/providers/jira/getJiraTicketDetails.js +3 -12
  100. package/dist/actions/providers/jira/getJiraTicketHistory.js +3 -12
  101. package/dist/actions/providers/jira/moveJiraTicketToProject.js +11 -21
  102. package/dist/actions/providers/jira/publicCommentOnServiceDeskRequest.js +3 -12
  103. package/dist/actions/providers/jira/updateJiraTicketDetails.js +15 -15
  104. package/dist/actions/providers/jira/updateJiraTicketStatus.js +4 -13
  105. package/dist/actions/providers/jira/utils.js +104 -126
  106. package/dist/actions/providers/linear/getIssueDetails.js +10 -20
  107. package/dist/actions/providers/linear/getIssues.js +11 -21
  108. package/dist/actions/providers/linear/getProjectDetails.js +10 -20
  109. package/dist/actions/providers/linear/getProjects.js +6 -16
  110. package/dist/actions/providers/linear/getTeamDetails.js +7 -17
  111. package/dist/actions/providers/linear/getTeams.js +5 -15
  112. package/dist/actions/providers/looker/enableUserByEmail.js +5 -14
  113. package/dist/actions/providers/math/add.js +2 -11
  114. package/dist/actions/providers/microsoft/createDocument.js +4 -13
  115. package/dist/actions/providers/microsoft/getDocument.js +4 -13
  116. package/dist/actions/providers/microsoft/messageTeamsChannel.js +4 -13
  117. package/dist/actions/providers/microsoft/messageTeamsChat.js +4 -13
  118. package/dist/actions/providers/microsoft/updateDocument.js +4 -13
  119. package/dist/actions/providers/microsoft/updateSpreadsheet.js +4 -13
  120. package/dist/actions/providers/microsoft/utils.js +9 -20
  121. package/dist/actions/providers/mongodb/insertMongoDoc.js +5 -14
  122. package/dist/actions/providers/notion/searchByTitle.js +3 -12
  123. package/dist/actions/providers/nws/getForecastForLocation.js +4 -13
  124. package/dist/actions/providers/oktaOrg/getOktaUserByName.js +3 -12
  125. package/dist/actions/providers/openstreetmap/getLatitudeLongitudeFromLocation.js +3 -12
  126. package/dist/actions/providers/perplexity/perplexityDeepResearch.js +11 -21
  127. package/dist/actions/providers/resend/sendEmail.js +3 -12
  128. package/dist/actions/providers/resend/sendEmailHtml.js +3 -12
  129. package/dist/actions/providers/salesforce/createCase.js +10 -13
  130. package/dist/actions/providers/salesforce/createRecord.js +3 -12
  131. package/dist/actions/providers/salesforce/executeReport.js +3 -12
  132. package/dist/actions/providers/salesforce/generateSalesReport.js +3 -12
  133. package/dist/actions/providers/salesforce/getRecord.js +3 -12
  134. package/dist/actions/providers/salesforce/getReportMetadata.js +11 -21
  135. package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +7 -17
  136. package/dist/actions/providers/salesforce/listReports.js +3 -12
  137. package/dist/actions/providers/salesforce/searchAllSalesforceRecords.js +3 -12
  138. package/dist/actions/providers/salesforce/searchSalesforceRecords.js +3 -12
  139. package/dist/actions/providers/salesforce/updateRecord.js +3 -12
  140. package/dist/actions/providers/slack/archiveChannel.js +9 -2
  141. package/dist/actions/providers/slack/createChannel.js +7 -17
  142. package/dist/actions/providers/slack/getChannelMembers.js +8 -18
  143. package/dist/actions/providers/slack/getChannelMessages.js +8 -18
  144. package/dist/actions/providers/slack/helpers.js +16 -47
  145. package/dist/actions/providers/slack/messageTransformers.js +10 -13
  146. package/dist/actions/providers/slack/sendDmFromBot.js +9 -19
  147. package/dist/actions/providers/slack/sendMessage.js +7 -17
  148. package/dist/actions/providers/slackUser/searchSlack.js +179 -212
  149. package/dist/actions/providers/slackUser/searchSlackRTS.js +20 -33
  150. package/dist/actions/providers/slackUser/utils.js +1 -1
  151. package/dist/actions/providers/snowflake/auth/getSnowflakeConnection.js +23 -34
  152. package/dist/actions/providers/snowflake/getRowByFieldValue.js +4 -13
  153. package/dist/actions/providers/snowflake/runSnowflakeQuery.js +9 -19
  154. package/dist/actions/providers/zendesk/addCommentToTicket.js +5 -14
  155. package/dist/actions/providers/zendesk/assignTicket.js +3 -12
  156. package/dist/actions/providers/zendesk/createZendeskTicket.js +3 -12
  157. package/dist/actions/providers/zendesk/getTicketDetails.js +3 -12
  158. package/dist/actions/providers/zendesk/listTickets.js +3 -12
  159. package/dist/actions/providers/zendesk/searchZendeskByQuery.js +3 -12
  160. package/dist/actions/providers/zendesk/updateTicketStatus.js +3 -12
  161. package/dist/actions/util/axiosClient.js +5 -5
  162. package/dist/app.js +14 -25
  163. package/dist/utils/google.js +122 -143
  164. package/dist/utils/pdf.js +10 -21
  165. package/package.json +10 -9
  166. package/dist/actions/providers/credal/callCopilot.d.ts +0 -3
  167. package/dist/actions/providers/credal/callCopilot.js +0 -36
  168. package/dist/actions/providers/math/index.d.ts +0 -1
  169. package/dist/actions/providers/math/index.js +0 -37
  170. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
  171. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
  172. package/dist/actions/providers/slack/index.d.ts +0 -1
  173. package/dist/actions/providers/slack/index.js +0 -37
  174. package/dist/actions/providers/slack/listConversations.d.ts +0 -3
  175. package/dist/actions/providers/slack/listConversations.js +0 -41
@@ -1,17 +1,7 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { asanaGetTasksDetailsOutputSchema } from "../../autogen/types.js";
11
2
  import { axiosClient } from "../../util/axiosClient.js";
12
3
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
13
- const getTasksDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
- var _b, _c, _d;
4
+ const getTasksDetails = async ({ params, authParams, }) => {
15
5
  const { authToken } = authParams;
16
6
  const { taskIds } = params;
17
7
  if (!authToken) {
@@ -23,7 +13,7 @@ const getTasksDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
23
13
  for (const taskId of taskIds) {
24
14
  try {
25
15
  // Get task details
26
- const taskResponse = yield axiosClient.get(`https://app.asana.com/api/1.0/tasks/${taskId}?opt_fields=name,notes,assignee,assignee.name,created_at,completed,due_at,approval_status`, {
16
+ const taskResponse = await axiosClient.get(`https://app.asana.com/api/1.0/tasks/${taskId}?opt_fields=name,notes,assignee,assignee.name,created_at,completed,due_at,approval_status`, {
27
17
  headers: { Authorization: `Bearer ${authToken}` },
28
18
  });
29
19
  const taskData = taskResponse.data.data;
@@ -32,46 +22,40 @@ const getTasksDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
32
22
  throw new Error(`No data returned for task ${taskId}`);
33
23
  }
34
24
  // Get the stories (comments)
35
- const storyResponse = yield axiosClient.get(`https://app.asana.com/api/1.0/tasks/${taskId}/stories?opt_fields=text,created_at,created_by,resource_subtype`, {
25
+ const storyResponse = await axiosClient.get(`https://app.asana.com/api/1.0/tasks/${taskId}/stories?opt_fields=text,created_at,created_by,resource_subtype`, {
36
26
  headers: { Authorization: `Bearer ${authToken}` },
37
27
  });
38
28
  // Filter and map comments
39
29
  const comments = storyResponse.data.data
40
30
  .filter(story => story.resource_subtype === "comment_added")
41
- .map(story => {
42
- var _a;
43
- return ({
44
- text: story.text,
45
- created_at: story.created_at,
46
- creator_name: ((_a = story.created_by) === null || _a === void 0 ? void 0 : _a.name) || "Unknown",
47
- });
48
- });
31
+ .map(story => ({
32
+ text: story.text,
33
+ created_at: story.created_at,
34
+ creator_name: story.created_by?.name || "Unknown",
35
+ }));
49
36
  // Handle pagination for comments
50
- let nextLink = (_b = storyResponse.data.next_page) === null || _b === void 0 ? void 0 : _b.uri;
37
+ let nextLink = storyResponse.data.next_page?.uri;
51
38
  while (nextLink) {
52
- const nextResponse = yield axiosClient.get(nextLink, {
39
+ const nextResponse = await axiosClient.get(nextLink, {
53
40
  headers: { Authorization: `Bearer ${authToken}` },
54
41
  });
55
42
  const nextData = nextResponse.data;
56
43
  // Filter for comments and add to the array
57
44
  const additionalComments = nextData.data
58
45
  .filter(story => story.resource_subtype === "comment_added")
59
- .map(story => {
60
- var _a;
61
- return ({
62
- text: story.text,
63
- created_at: story.created_at,
64
- creator_name: ((_a = story.created_by) === null || _a === void 0 ? void 0 : _a.name) || "Unknown",
65
- });
66
- });
46
+ .map(story => ({
47
+ text: story.text,
48
+ created_at: story.created_at,
49
+ creator_name: story.created_by?.name || "Unknown",
50
+ }));
67
51
  comments.push(...additionalComments);
68
- nextLink = (_c = nextResponse.data.next_page) === null || _c === void 0 ? void 0 : _c.uri;
52
+ nextLink = nextResponse.data.next_page?.uri;
69
53
  }
70
54
  const taskDetails = {
71
55
  id: taskData.gid,
72
56
  name: taskData.name || "",
73
57
  notes: taskData.notes || "",
74
- assignee_name: ((_d = taskData.assignee) === null || _d === void 0 ? void 0 : _d.name) || "",
58
+ assignee_name: taskData.assignee?.name || "",
75
59
  approval_status: taskData.approval_status || "",
76
60
  completed: taskData.completed || false,
77
61
  created_at: taskData.created_at || "",
@@ -93,5 +77,5 @@ const getTasksDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
93
77
  results: tasks,
94
78
  };
95
79
  return asanaGetTasksDetailsOutputSchema.parse(result);
96
- });
80
+ };
97
81
  export default getTasksDetails;
@@ -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 { z } from "zod";
11
2
  import axios from "axios";
12
3
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
@@ -68,97 +59,89 @@ const AsanaOutputSchema = z.object({
68
59
  }),
69
60
  next_page: NextPageSchema,
70
61
  });
71
- function getTaskIdsFromProject(authToken, projectId) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- let nextPage = undefined;
74
- const tasks = [];
75
- do {
76
- const response = yield axios.get(`https://app.asana.com/api/1.0/projects/${projectId}/tasks`, {
77
- headers: { Authorization: `Bearer ${authToken}` },
78
- params: {
79
- limit: 100,
80
- completed_since: "now",
81
- offset: nextPage ? nextPage.offset : undefined,
82
- },
83
- });
84
- const parsedTasks = z.array(TaskSchema).safeParse(response.data.data);
85
- if (!parsedTasks.success) {
86
- return tasks;
87
- }
88
- tasks.push(...parsedTasks.data.map(task => task.gid).filter((gid) => gid !== undefined));
89
- nextPage = response.data.next_page;
90
- } while (nextPage);
91
- return tasks;
92
- });
93
- }
94
- // Only handles the first layer of subtasks, not nested ones
95
- function getSubtasksFromTask(authToken, taskId) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- let nextPage = undefined;
98
- const subtasks = [];
99
- do {
100
- const response = yield axios.get(`https://app.asana.com/api/1.0/tasks/${taskId}/subtasks`, {
101
- headers: { Authorization: `Bearer ${authToken}` },
102
- params: {
103
- limit: 100,
104
- offset: nextPage ? nextPage.offset : undefined,
105
- },
106
- });
107
- const parsedSubtasks = z.array(TaskSchema).safeParse(response.data.data);
108
- if (!parsedSubtasks.success) {
109
- return subtasks;
110
- }
111
- subtasks.push(...parsedSubtasks.data);
112
- nextPage = response.data.next_page;
113
- } while (nextPage);
114
- return subtasks;
115
- });
116
- }
117
- function getTaskDetails(authToken, taskId) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- const response = yield axios.get(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
62
+ async function getTaskIdsFromProject(authToken, projectId) {
63
+ let nextPage = undefined;
64
+ const tasks = [];
65
+ do {
66
+ const response = await axios.get(`https://app.asana.com/api/1.0/projects/${projectId}/tasks`, {
120
67
  headers: { Authorization: `Bearer ${authToken}` },
121
68
  params: {
122
- options: {
123
- fields: ["num_subtasks"],
124
- },
69
+ limit: 100,
70
+ completed_since: "now",
71
+ offset: nextPage ? nextPage.offset : undefined,
125
72
  },
126
73
  });
127
- const parsedTask = TaskDetailsSchema.safeParse(response.data.data);
128
- if (!parsedTask.success) {
129
- return null;
74
+ const parsedTasks = z.array(TaskSchema).safeParse(response.data.data);
75
+ if (!parsedTasks.success) {
76
+ return tasks;
130
77
  }
131
- return parsedTask.data;
132
- });
78
+ tasks.push(...parsedTasks.data.map(task => task.gid).filter((gid) => gid !== undefined));
79
+ nextPage = response.data.next_page;
80
+ } while (nextPage);
81
+ return tasks;
133
82
  }
134
- function getTaskStories(authToken, taskId) {
135
- return __awaiter(this, void 0, void 0, function* () {
136
- const response = yield axios.get(`https://app.asana.com/api/1.0/tasks/${taskId}/stories`, {
83
+ // Only handles the first layer of subtasks, not nested ones
84
+ async function getSubtasksFromTask(authToken, taskId) {
85
+ let nextPage = undefined;
86
+ const subtasks = [];
87
+ do {
88
+ const response = await axios.get(`https://app.asana.com/api/1.0/tasks/${taskId}/subtasks`, {
137
89
  headers: { Authorization: `Bearer ${authToken}` },
90
+ params: {
91
+ limit: 100,
92
+ offset: nextPage ? nextPage.offset : undefined,
93
+ },
138
94
  });
139
- const parsedTask = z.array(TaskStorySchema).safeParse(response.data.data);
140
- if (!parsedTask.success) {
141
- return null;
95
+ const parsedSubtasks = z.array(TaskSchema).safeParse(response.data.data);
96
+ if (!parsedSubtasks.success) {
97
+ return subtasks;
142
98
  }
143
- return parsedTask.data;
99
+ subtasks.push(...parsedSubtasks.data);
100
+ nextPage = response.data.next_page;
101
+ } while (nextPage);
102
+ return subtasks;
103
+ }
104
+ async function getTaskDetails(authToken, taskId) {
105
+ const response = await axios.get(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
106
+ headers: { Authorization: `Bearer ${authToken}` },
107
+ params: {
108
+ options: {
109
+ fields: ["num_subtasks"],
110
+ },
111
+ },
144
112
  });
113
+ const parsedTask = TaskDetailsSchema.safeParse(response.data.data);
114
+ if (!parsedTask.success) {
115
+ return null;
116
+ }
117
+ return parsedTask.data;
118
+ }
119
+ async function getTaskStories(authToken, taskId) {
120
+ const response = await axios.get(`https://app.asana.com/api/1.0/tasks/${taskId}/stories`, {
121
+ headers: { Authorization: `Bearer ${authToken}` },
122
+ });
123
+ const parsedTask = z.array(TaskStorySchema).safeParse(response.data.data);
124
+ if (!parsedTask.success) {
125
+ return null;
126
+ }
127
+ return parsedTask.data;
145
128
  }
146
- const listAsanaTasksByProject = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
129
+ const listAsanaTasksByProject = async ({ params, authParams, }) => {
147
130
  const { authToken } = authParams;
148
131
  const { projectId } = params;
149
132
  if (!authToken) {
150
133
  return { success: false, error: MISSING_AUTH_TOKEN };
151
134
  }
152
135
  try {
153
- const taskIds = yield getTaskIdsFromProject(authToken, projectId);
136
+ const taskIds = await getTaskIdsFromProject(authToken, projectId);
154
137
  const tasks = [];
155
138
  for (const taskId of taskIds) {
156
- const task = yield getTaskDetails(authToken, taskId);
139
+ const task = await getTaskDetails(authToken, taskId);
157
140
  if (!task) {
158
141
  continue;
159
142
  }
160
- const subtasks = yield getSubtasksFromTask(authToken, taskId);
161
- const taskStories = yield getTaskStories(authToken, taskId);
143
+ const subtasks = await getSubtasksFromTask(authToken, taskId);
144
+ const taskStories = await getTaskStories(authToken, taskId);
162
145
  tasks.push({
163
146
  task,
164
147
  subtasks,
@@ -177,5 +160,5 @@ const listAsanaTasksByProject = (_a) => __awaiter(void 0, [_a], void 0, function
177
160
  error: error instanceof Error ? error.message : "Unknown error",
178
161
  };
179
162
  }
180
- });
163
+ };
181
164
  export default listAsanaTasksByProject;
@@ -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 searchAsanaTasks = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
- var _b, _c;
3
+ const searchAsanaTasks = async ({ params, authParams, }) => {
14
4
  const { authToken } = authParams;
15
5
  const { query } = params;
16
6
  if (!authToken) {
@@ -18,10 +8,10 @@ const searchAsanaTasks = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
18
8
  }
19
9
  try {
20
10
  // search api only searches within a workspace, so fetch all workspaces first
21
- const workspacesResponse = yield axiosClient.get("https://app.asana.com/api/1.0/workspaces", {
11
+ const workspacesResponse = await axiosClient.get("https://app.asana.com/api/1.0/workspaces", {
22
12
  headers: { Authorization: `Bearer ${authToken}` },
23
13
  });
24
- const workspaces = (_b = workspacesResponse === null || workspacesResponse === void 0 ? void 0 : workspacesResponse.data) === null || _b === void 0 ? void 0 : _b.data;
14
+ const workspaces = workspacesResponse?.data?.data;
25
15
  if (!Array.isArray(workspaces) || workspaces.length === 0) {
26
16
  throw new Error("No workspaces found");
27
17
  }
@@ -29,13 +19,13 @@ const searchAsanaTasks = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
29
19
  for (const workspace of workspaces) {
30
20
  const workspaceId = workspace.gid;
31
21
  try {
32
- const searchResponse = yield axiosClient.get(`https://app.asana.com/api/1.0/workspaces/${workspaceId}/tasks/search`, {
22
+ const searchResponse = await axiosClient.get(`https://app.asana.com/api/1.0/workspaces/${workspaceId}/tasks/search`, {
33
23
  headers: { Authorization: `Bearer ${authToken}` },
34
24
  params: {
35
25
  text: query,
36
26
  },
37
27
  });
38
- const tasks = (_c = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.data) === null || _c === void 0 ? void 0 : _c.data;
28
+ const tasks = searchResponse?.data?.data;
39
29
  if (Array.isArray(tasks)) {
40
30
  matches.push(...tasks.map(({ gid, name, resource_type }) => ({
41
31
  id: gid,
@@ -61,5 +51,5 @@ const searchAsanaTasks = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
61
51
  error: error instanceof Error ? error.message : "Unknown error",
62
52
  };
63
53
  }
64
- });
54
+ };
65
55
  export default searchAsanaTasks;
@@ -1,35 +1,36 @@
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 { getUserIdByEmail, getWorkspaceIdAndPermalinkFromTask } from "./utils.js";
13
- const updateAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
4
+ const updateAsanaTask = async ({ params, authParams, }) => {
14
5
  const { authToken } = authParams;
15
6
  const { name, taskId, description, customFields, completed, assignee, approvalStatus, dueAt } = params;
16
7
  if (!authToken) {
17
8
  return { success: false, error: MISSING_AUTH_TOKEN };
18
9
  }
19
- const { workspaceId, permalinkUrl } = yield getWorkspaceIdAndPermalinkFromTask(taskId, authToken);
10
+ const { workspaceId, permalinkUrl } = await getWorkspaceIdAndPermalinkFromTask(taskId, authToken);
20
11
  if (!workspaceId || !permalinkUrl) {
21
12
  return { success: false, error: "Task ID invalid: unable to get workspaceID or permalink" };
22
13
  }
23
14
  let assigneeId;
24
15
  if (assignee && assignee.includes("@")) {
25
- assigneeId = yield getUserIdByEmail(authToken, workspaceId, assignee);
16
+ assigneeId = await getUserIdByEmail(authToken, workspaceId, assignee);
26
17
  }
27
18
  else {
28
19
  assigneeId = assignee;
29
20
  }
30
21
  try {
31
- yield axiosClient.put(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
32
- data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ workspace: workspaceId }, (name && { name })), (approvalStatus && completed === undefined && { approval_status: approvalStatus })), (assigneeId && { assignee: assigneeId })), (completed !== undefined && { completed })), (customFields && { custom_fields: customFields })), (description && { notes: description })), (dueAt && { due_at: dueAt })),
22
+ await axiosClient.put(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
23
+ data: {
24
+ workspace: workspaceId,
25
+ ...(name && { name }),
26
+ // only 1 of approvalStatus and completed can be set, so only set approvalStatus if completed is undefined
27
+ ...(approvalStatus && completed === undefined && { approval_status: approvalStatus }),
28
+ ...(assigneeId && { assignee: assigneeId }),
29
+ ...(completed !== undefined && { completed }),
30
+ ...(customFields && { custom_fields: customFields }),
31
+ ...(description && { notes: description }),
32
+ ...(dueAt && { due_at: dueAt }),
33
+ },
33
34
  }, {
34
35
  headers: { Authorization: `Bearer ${authToken}` },
35
36
  });
@@ -45,5 +46,5 @@ const updateAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
45
46
  error: error instanceof Error ? error.message : "Unknown error",
46
47
  };
47
48
  }
48
- });
49
+ };
49
50
  export default updateAsanaTask;
@@ -1,68 +1,51 @@
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
- export function getWorkspaceIdFromProject(projectId, authToken) {
12
- return __awaiter(this, void 0, void 0, function* () {
13
- var _a, _b, _c;
14
- if (!projectId || !authToken) {
15
- console.error("Project ID and authToken are required");
16
- return null;
17
- }
18
- try {
19
- const response = yield axiosClient.get(`https://app.asana.com/api/1.0/projects/${projectId}`, {
20
- headers: { Authorization: `Bearer ${authToken}` },
21
- });
22
- return ((_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.workspace) === null || _c === void 0 ? void 0 : _c.gid) || null;
23
- }
24
- catch (error) {
25
- console.error("Error fetching workspace ID from project:", error);
26
- return null;
27
- }
28
- });
2
+ export async function getWorkspaceIdFromProject(projectId, authToken) {
3
+ if (!projectId || !authToken) {
4
+ console.error("Project ID and authToken are required");
5
+ return null;
6
+ }
7
+ try {
8
+ const response = await axiosClient.get(`https://app.asana.com/api/1.0/projects/${projectId}`, {
9
+ headers: { Authorization: `Bearer ${authToken}` },
10
+ });
11
+ return response.data?.data?.workspace?.gid || null;
12
+ }
13
+ catch (error) {
14
+ console.error("Error fetching workspace ID from project:", error);
15
+ return null;
16
+ }
29
17
  }
30
- export function getWorkspaceIdAndPermalinkFromTask(taskId, authToken) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- var _a, _b, _c, _d, _e;
33
- if (!taskId || !authToken) {
34
- console.error("Task ID and authToken are required");
35
- return { workspaceId: null, permalinkUrl: null };
36
- }
37
- try {
38
- const response = yield axiosClient.get(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
39
- headers: { Authorization: `Bearer ${authToken}` },
40
- });
41
- const workspaceId = ((_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.workspace) === null || _c === void 0 ? void 0 : _c.gid) || null;
42
- const permalinkUrl = ((_e = (_d = response.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.permalink_url) || null; // Gets the task's URL
43
- return { workspaceId, permalinkUrl };
44
- }
45
- catch (error) {
46
- console.error("Error fetching workspace ID and permalink URL from task:", error);
47
- return { workspaceId: null, permalinkUrl: null };
48
- }
49
- });
18
+ export async function getWorkspaceIdAndPermalinkFromTask(taskId, authToken) {
19
+ if (!taskId || !authToken) {
20
+ console.error("Task ID and authToken are required");
21
+ return { workspaceId: null, permalinkUrl: null };
22
+ }
23
+ try {
24
+ const response = await axiosClient.get(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
25
+ headers: { Authorization: `Bearer ${authToken}` },
26
+ });
27
+ const workspaceId = response.data?.data?.workspace?.gid || null;
28
+ const permalinkUrl = response.data?.data?.permalink_url || null; // Gets the task's URL
29
+ return { workspaceId, permalinkUrl };
30
+ }
31
+ catch (error) {
32
+ console.error("Error fetching workspace ID and permalink URL from task:", error);
33
+ return { workspaceId: null, permalinkUrl: null };
34
+ }
50
35
  }
51
- export function getUserIdByEmail(authToken, workspaceId, email) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- // Get all users in the workspace
54
- const url = `https://app.asana.com/api/1.0/workspaces/${workspaceId}/users?opt_fields=email,name,gid`;
55
- try {
56
- const response = yield axiosClient.get(url, {
57
- headers: { Authorization: `Bearer ${authToken}` },
58
- });
59
- // Filter the users by email on the client side
60
- const matchingUser = response.data.data.find((user) => user.email && user.email.toLowerCase() === email.toLowerCase());
61
- return matchingUser ? matchingUser.gid : null;
62
- }
63
- catch (error) {
64
- console.error("Error fetching users:", error);
65
- return null;
66
- }
67
- });
36
+ export async function getUserIdByEmail(authToken, workspaceId, email) {
37
+ // Get all users in the workspace
38
+ const url = `https://app.asana.com/api/1.0/workspaces/${workspaceId}/users?opt_fields=email,name,gid`;
39
+ try {
40
+ const response = await axiosClient.get(url, {
41
+ headers: { Authorization: `Bearer ${authToken}` },
42
+ });
43
+ // Filter the users by email on the client side
44
+ const matchingUser = response.data.data.find((user) => user.email && user.email.toLowerCase() === email.toLowerCase());
45
+ return matchingUser ? matchingUser.gid : null;
46
+ }
47
+ catch (error) {
48
+ console.error("Error fetching users:", error);
49
+ return null;
50
+ }
68
51
  }
@@ -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 { bingGetTopNSearchResultUrlsOutputSchema, } from "../../autogen/types.js";
11
2
  import { axiosClient } from "../../util/axiosClient.js";
12
- const getTopNSearchResultUrls = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
- var _b;
3
+ const getTopNSearchResultUrls = async ({ params, authParams, }) => {
14
4
  const { query, count = 5, site } = params;
15
5
  const { apiKey } = authParams;
16
6
  // Build the search query
@@ -21,7 +11,7 @@ const getTopNSearchResultUrls = (_a) => __awaiter(void 0, [_a], void 0, function
21
11
  }
22
12
  try {
23
13
  // Call Bing Search API
24
- const response = yield axiosClient.get("https://api.bing.microsoft.com/v7.0/search", {
14
+ const response = await axiosClient.get("https://api.bing.microsoft.com/v7.0/search", {
25
15
  params: {
26
16
  q: searchQuery,
27
17
  count: count,
@@ -33,7 +23,7 @@ const getTopNSearchResultUrls = (_a) => __awaiter(void 0, [_a], void 0, function
33
23
  },
34
24
  });
35
25
  // Extract URLs and names from search results
36
- const searchResults = ((_b = response.data.webPages) === null || _b === void 0 ? void 0 : _b.value) || [];
26
+ const searchResults = response.data.webPages?.value || [];
37
27
  return bingGetTopNSearchResultUrlsOutputSchema.parse({
38
28
  results: searchResults,
39
29
  });
@@ -42,5 +32,5 @@ const getTopNSearchResultUrls = (_a) => __awaiter(void 0, [_a], void 0, function
42
32
  console.error("Error fetching search results from Bing:", error);
43
33
  throw error;
44
34
  }
45
- });
35
+ };
46
36
  export default getTopNSearchResultUrls;
@@ -1,24 +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 { getConfluenceRequestConfig } from "./helpers.js";
11
2
  import { axiosClient } from "../../util/axiosClient.js";
12
3
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
13
- const confluenceFetchPageContent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
- var _b, _c;
4
+ const confluenceFetchPageContent = async ({ params, authParams, }) => {
15
5
  const { pageId } = params;
16
6
  const { authToken } = authParams;
17
7
  if (!authToken) {
18
8
  throw new Error(MISSING_AUTH_TOKEN);
19
9
  }
20
10
  try {
21
- const cloudDetails = yield axiosClient.get("https://api.atlassian.com/oauth/token/accessible-resources", {
11
+ const cloudDetails = await axiosClient.get("https://api.atlassian.com/oauth/token/accessible-resources", {
22
12
  headers: {
23
13
  Authorization: `Bearer ${authToken}`,
24
14
  },
@@ -27,10 +17,10 @@ const confluenceFetchPageContent = (_a) => __awaiter(void 0, [_a], void 0, funct
27
17
  const baseUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/api/v2`;
28
18
  const config = getConfluenceRequestConfig(baseUrl, authToken);
29
19
  // Get page content and metadata
30
- const response = yield axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
20
+ const response = await axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
31
21
  // Extract needed data from response
32
22
  const title = response.data.title;
33
- const content = ((_c = (_b = response.data.body) === null || _b === void 0 ? void 0 : _b.storage) === null || _c === void 0 ? void 0 : _c.value) || "";
23
+ const content = response.data.body?.storage?.value || "";
34
24
  return {
35
25
  success: true,
36
26
  data: {
@@ -48,5 +38,5 @@ const confluenceFetchPageContent = (_a) => __awaiter(void 0, [_a], void 0, funct
48
38
  : "An unknown error occurred while fetching the Confluence page content.",
49
39
  };
50
40
  }
51
- });
41
+ };
52
42
  export default confluenceFetchPageContent;
@@ -1,22 +1,13 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { axiosClient } from "../../util/axiosClient.js";
11
2
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
3
  import { getConfluenceRequestConfig } from "./helpers.js";
13
- const confluenceOverwritePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
4
+ const confluenceOverwritePage = async ({ params, authParams, }) => {
14
5
  const { pageId, content, title } = params;
15
6
  const { authToken } = authParams;
16
7
  if (!authToken) {
17
8
  throw new Error(MISSING_AUTH_TOKEN);
18
9
  }
19
- const cloudDetails = yield axiosClient.get("https://api.atlassian.com/oauth/token/accessible-resources", {
10
+ const cloudDetails = await axiosClient.get("https://api.atlassian.com/oauth/token/accessible-resources", {
20
11
  headers: {
21
12
  Authorization: `Bearer ${authToken}`,
22
13
  },
@@ -26,7 +17,7 @@ const confluenceOverwritePage = (_a) => __awaiter(void 0, [_a], void 0, function
26
17
  try {
27
18
  const config = getConfluenceRequestConfig(baseUrl, authToken);
28
19
  // Get current page content and version number
29
- const response = yield axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
20
+ const response = await axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
30
21
  const currVersion = response.data.version.number;
31
22
  const payload = {
32
23
  id: pageId,
@@ -40,7 +31,7 @@ const confluenceOverwritePage = (_a) => __awaiter(void 0, [_a], void 0, function
40
31
  number: currVersion + 1,
41
32
  },
42
33
  };
43
- yield axiosClient.put(`/pages/${pageId}`, payload, config);
34
+ await axiosClient.put(`/pages/${pageId}`, payload, config);
44
35
  return {
45
36
  success: true,
46
37
  };
@@ -51,5 +42,5 @@ const confluenceOverwritePage = (_a) => __awaiter(void 0, [_a], void 0, function
51
42
  error: error instanceof Error ? error.message : "An unknown error occurred while updating the Confluence page.",
52
43
  };
53
44
  }
54
- });
45
+ };
55
46
  export default confluenceOverwritePage;