@credal/actions 0.2.196 → 0.2.198

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 (216) hide show
  1. package/dist/actions/autogen/templates.js +8 -12
  2. package/dist/actions/autogen/types.js +26 -8
  3. package/dist/actions/groups.d.ts +6 -0
  4. package/dist/actions/groups.js +251 -0
  5. package/dist/actions/invoke.js +11 -22
  6. package/dist/actions/parse.js +231 -244
  7. package/dist/actions/providers/asana/commentAsanaTask.js +8 -15
  8. package/dist/actions/providers/asana/createAsanaTask.js +20 -21
  9. package/dist/actions/providers/asana/getTasksDetails.js +18 -34
  10. package/dist/actions/providers/asana/listAsanaTasksByProject.js +62 -79
  11. package/dist/actions/providers/asana/searchAsanaTasks.js +6 -16
  12. package/dist/actions/providers/asana/updateAsanaTask.js +16 -15
  13. package/dist/actions/providers/asana/utils.js +47 -64
  14. package/dist/actions/providers/ashby/addCandidateToProject.d.ts +3 -0
  15. package/dist/actions/providers/ashby/addCandidateToProject.js +31 -0
  16. package/dist/actions/providers/ashby/createCandidate.d.ts +3 -0
  17. package/dist/actions/providers/ashby/createCandidate.js +38 -0
  18. package/dist/actions/providers/ashby/createNote.d.ts +3 -0
  19. package/dist/actions/providers/ashby/createNote.js +31 -0
  20. package/dist/actions/providers/ashby/getCandidateInfo.d.ts +3 -0
  21. package/dist/actions/providers/ashby/getCandidateInfo.js +33 -0
  22. package/dist/actions/providers/ashby/listCandidateNotes.d.ts +3 -0
  23. package/dist/actions/providers/ashby/listCandidateNotes.js +33 -0
  24. package/dist/actions/providers/ashby/listCandidates.d.ts +3 -0
  25. package/dist/actions/providers/ashby/listCandidates.js +30 -0
  26. package/dist/actions/providers/ashby/searchCandidates.d.ts +3 -0
  27. package/dist/actions/providers/ashby/searchCandidates.js +34 -0
  28. package/dist/actions/providers/ashby/updateCandidate.d.ts +3 -0
  29. package/dist/actions/providers/ashby/updateCandidate.js +56 -0
  30. package/dist/actions/providers/bing/getTopNSearchResultUrls.js +4 -14
  31. package/dist/actions/providers/confluence/fetchPageContent.js +5 -15
  32. package/dist/actions/providers/confluence/overwritePage.js +5 -14
  33. package/dist/actions/providers/finnhub/getBasicFinancials.js +7 -19
  34. package/dist/actions/providers/finnhub/symbolLookup.js +3 -12
  35. package/dist/actions/providers/firecrawl/deepResearch.js +11 -21
  36. package/dist/actions/providers/firecrawl/getTopNSearchResultUrls.js +8 -21
  37. package/dist/actions/providers/firecrawl/scrapeTweetDataWithNitter.js +4 -13
  38. package/dist/actions/providers/firecrawl/scrapeUrl.js +16 -21
  39. package/dist/actions/providers/firecrawl/searchAndScrape.js +6 -17
  40. package/dist/actions/providers/generic/fillTemplate.js +2 -11
  41. package/dist/actions/providers/github/createBranch.js +9 -18
  42. package/dist/actions/providers/github/createOrUpdateFile.js +6 -15
  43. package/dist/actions/providers/github/createPullRequest.js +5 -14
  44. package/dist/actions/providers/github/fetchFile.d.ts +3 -0
  45. package/dist/actions/providers/github/fetchFile.js +131 -0
  46. package/dist/actions/providers/github/getBranch.js +4 -13
  47. package/dist/actions/providers/github/getContents.d.ts +3 -0
  48. package/dist/actions/providers/github/getContents.js +41 -0
  49. package/dist/actions/providers/github/getFileContent.js +6 -16
  50. package/dist/actions/providers/github/getPullRequestDetails.js +39 -18
  51. package/dist/actions/providers/github/listCommits.js +17 -15
  52. package/dist/actions/providers/github/listDirectory.js +13 -25
  53. package/dist/actions/providers/github/listPullRequests.js +4 -13
  54. package/dist/actions/providers/github/searchOrganization.js +29 -49
  55. package/dist/actions/providers/github/utils.js +5 -16
  56. package/dist/actions/providers/gitlab/getFileContent.js +13 -24
  57. package/dist/actions/providers/gitlab/getMergeRequest.js +18 -30
  58. package/dist/actions/providers/gitlab/listDirectory.js +15 -27
  59. package/dist/actions/providers/gitlab/searchGroup.js +45 -52
  60. package/dist/actions/providers/gitlab/utils.js +19 -32
  61. package/dist/actions/providers/gong/getGongTranscripts.d.ts +3 -0
  62. package/dist/actions/providers/gong/getGongTranscripts.js +315 -0
  63. package/dist/actions/providers/google-oauth/addGroupMember.js +3 -12
  64. package/dist/actions/providers/google-oauth/addTextToTopOfDoc.js +3 -12
  65. package/dist/actions/providers/google-oauth/appendRowsToSpreadsheet.js +4 -13
  66. package/dist/actions/providers/google-oauth/createNewGoogleDoc.js +7 -17
  67. package/dist/actions/providers/google-oauth/createPresentation.js +7 -13
  68. package/dist/actions/providers/google-oauth/createSpreadsheet.js +7 -13
  69. package/dist/actions/providers/google-oauth/deleteCalendarEvent.js +3 -12
  70. package/dist/actions/providers/google-oauth/deleteGroupMember.js +3 -12
  71. package/dist/actions/providers/google-oauth/deleteRowFromSpreadsheet.js +3 -12
  72. package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.js +4 -14
  73. package/dist/actions/providers/google-oauth/getDriveFileContentById.js +23 -33
  74. package/dist/actions/providers/google-oauth/getGroup.js +3 -12
  75. package/dist/actions/providers/google-oauth/getPresentation.js +23 -37
  76. package/dist/actions/providers/google-oauth/hasGroupMember.js +3 -12
  77. package/dist/actions/providers/google-oauth/listCalendarEvents.js +27 -21
  78. package/dist/actions/providers/google-oauth/listCalendars.js +4 -14
  79. package/dist/actions/providers/google-oauth/listGroupMembers.js +4 -13
  80. package/dist/actions/providers/google-oauth/listGroups.js +4 -14
  81. package/dist/actions/providers/google-oauth/queryGoogleBigQuery.js +10 -21
  82. package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +11 -14
  83. package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +3 -12
  84. package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +12 -23
  85. package/dist/actions/providers/google-oauth/searchDriveByQuery.js +30 -42
  86. package/dist/actions/providers/google-oauth/searchDriveByQueryAndGetFileContent.js +9 -20
  87. package/dist/actions/providers/google-oauth/updateCalendarEvent.js +3 -12
  88. package/dist/actions/providers/google-oauth/updateDoc.js +3 -12
  89. package/dist/actions/providers/google-oauth/updatePresentation.js +3 -12
  90. package/dist/actions/providers/google-oauth/updateRowsInSpreadsheet.js +4 -13
  91. package/dist/actions/providers/google-oauth/updateSpreadsheet.js +3 -12
  92. package/dist/actions/providers/google-oauth/utils/decodeMessage.js +7 -8
  93. package/dist/actions/providers/googleSearch/customSearch.js +18 -36
  94. package/dist/actions/providers/googlemail/listGmailThreads.js +7 -16
  95. package/dist/actions/providers/googlemail/searchGmailMessages.js +10 -20
  96. package/dist/actions/providers/googlemail/sendGmail.js +7 -17
  97. package/dist/actions/providers/googlemaps/nearbysearchRestaurants.js +13 -25
  98. package/dist/actions/providers/googlemaps/validateAddress.js +3 -12
  99. package/dist/actions/providers/hubspot/getCompanies.js +4 -14
  100. package/dist/actions/providers/hubspot/getCompanyDetails.js +3 -12
  101. package/dist/actions/providers/hubspot/getContactDetails.js +3 -12
  102. package/dist/actions/providers/hubspot/getContacts.js +4 -14
  103. package/dist/actions/providers/hubspot/getDealDetails.js +3 -12
  104. package/dist/actions/providers/hubspot/getDeals.js +3 -12
  105. package/dist/actions/providers/hubspot/getTicketDetails.js +3 -12
  106. package/dist/actions/providers/hubspot/getTickets.js +3 -12
  107. package/dist/actions/providers/jamf/getJamfComputerInventory.d.ts +3 -0
  108. package/dist/actions/providers/jamf/getJamfComputerInventory.js +37 -0
  109. package/dist/actions/providers/jamf/getJamfFileVaultRecoveryKey.d.ts +3 -0
  110. package/dist/actions/providers/jamf/getJamfFileVaultRecoveryKey.js +39 -0
  111. package/dist/actions/providers/jamf/getJamfUserComputerId.d.ts +3 -0
  112. package/dist/actions/providers/jamf/getJamfUserComputerId.js +45 -0
  113. package/dist/actions/providers/jamf/lockJamfComputerById.d.ts +3 -0
  114. package/dist/actions/providers/jamf/lockJamfComputerById.js +39 -0
  115. package/dist/actions/providers/jira/assignJiraTicket.js +4 -13
  116. package/dist/actions/providers/jira/commentJiraTicket.js +3 -12
  117. package/dist/actions/providers/jira/createJiraTicket.js +22 -18
  118. package/dist/actions/providers/jira/createServiceDeskRequest.js +3 -12
  119. package/dist/actions/providers/jira/getJiraDCIssuesByQuery.js +5 -14
  120. package/dist/actions/providers/jira/getJiraIssuesByQuery.js +19 -29
  121. package/dist/actions/providers/jira/getJiraTicketDetails.js +3 -12
  122. package/dist/actions/providers/jira/getJiraTicketHistory.js +3 -12
  123. package/dist/actions/providers/jira/moveJiraTicketToProject.js +11 -21
  124. package/dist/actions/providers/jira/publicCommentOnServiceDeskRequest.js +3 -12
  125. package/dist/actions/providers/jira/updateJiraTicketDetails.js +15 -15
  126. package/dist/actions/providers/jira/updateJiraTicketStatus.js +4 -13
  127. package/dist/actions/providers/jira/utils.js +104 -126
  128. package/dist/actions/providers/kandji/getFVRecoveryKeyForDevice.d.ts +3 -0
  129. package/dist/actions/providers/kandji/getFVRecoveryKeyForDevice.js +85 -0
  130. package/dist/actions/providers/linear/getIssueDetails.js +10 -20
  131. package/dist/actions/providers/linear/getIssues.js +11 -21
  132. package/dist/actions/providers/linear/getProjectDetails.js +10 -20
  133. package/dist/actions/providers/linear/getProjects.js +6 -16
  134. package/dist/actions/providers/linear/getTeamDetails.js +7 -17
  135. package/dist/actions/providers/linear/getTeams.js +5 -15
  136. package/dist/actions/providers/looker/enableUserByEmail.js +5 -14
  137. package/dist/actions/providers/math/add.js +2 -11
  138. package/dist/actions/providers/microsoft/createDocument.js +4 -13
  139. package/dist/actions/providers/microsoft/getDocument.js +4 -13
  140. package/dist/actions/providers/microsoft/messageTeamsChannel.js +4 -13
  141. package/dist/actions/providers/microsoft/messageTeamsChat.js +4 -13
  142. package/dist/actions/providers/microsoft/updateDocument.js +4 -13
  143. package/dist/actions/providers/microsoft/updateSpreadsheet.js +4 -13
  144. package/dist/actions/providers/microsoft/utils.js +9 -20
  145. package/dist/actions/providers/mongodb/insertMongoDoc.js +5 -14
  146. package/dist/actions/providers/notion/searchByTitle.js +3 -12
  147. package/dist/actions/providers/nws/getForecastForLocation.js +4 -13
  148. package/dist/actions/providers/okta/addUserToGroup.d.ts +3 -0
  149. package/dist/actions/providers/okta/addUserToGroup.js +56 -0
  150. package/dist/actions/providers/okta/getOktaGroup.d.ts +3 -0
  151. package/dist/actions/providers/okta/getOktaGroup.js +73 -0
  152. package/dist/actions/providers/okta/getOktaUser.d.ts +3 -0
  153. package/dist/actions/providers/okta/getOktaUser.js +40 -0
  154. package/dist/actions/providers/okta/listMFA.d.ts +3 -0
  155. package/dist/actions/providers/okta/listMFA.js +52 -0
  156. package/dist/actions/providers/okta/listOktaGroupMembers.d.ts +3 -0
  157. package/dist/actions/providers/okta/listOktaGroupMembers.js +99 -0
  158. package/dist/actions/providers/okta/listOktaGroups.d.ts +3 -0
  159. package/dist/actions/providers/okta/listOktaGroups.js +92 -0
  160. package/dist/actions/providers/okta/listOktaUserGroups.d.ts +3 -0
  161. package/dist/actions/providers/okta/listOktaUserGroups.js +83 -0
  162. package/dist/actions/providers/okta/listOktaUsers.d.ts +3 -0
  163. package/dist/actions/providers/okta/listOktaUsers.js +100 -0
  164. package/dist/actions/providers/okta/removeUserFromGroup.d.ts +3 -0
  165. package/dist/actions/providers/okta/removeUserFromGroup.js +56 -0
  166. package/dist/actions/providers/okta/resetMFA.d.ts +3 -0
  167. package/dist/actions/providers/okta/resetMFA.js +62 -0
  168. package/dist/actions/providers/okta/resetPassword.d.ts +3 -0
  169. package/dist/actions/providers/okta/resetPassword.js +57 -0
  170. package/dist/actions/providers/okta/triggerOktaWorkflow.d.ts +3 -0
  171. package/dist/actions/providers/okta/triggerOktaWorkflow.js +44 -0
  172. package/dist/actions/providers/oktaOrg/getOktaUserByName.js +3 -12
  173. package/dist/actions/providers/openstreetmap/getLatitudeLongitudeFromLocation.js +3 -12
  174. package/dist/actions/providers/perplexity/perplexityDeepResearch.js +11 -21
  175. package/dist/actions/providers/resend/sendEmail.js +3 -12
  176. package/dist/actions/providers/resend/sendEmailHtml.js +3 -12
  177. package/dist/actions/providers/salesforce/createCase.js +10 -13
  178. package/dist/actions/providers/salesforce/createRecord.js +3 -12
  179. package/dist/actions/providers/salesforce/executeReport.js +3 -12
  180. package/dist/actions/providers/salesforce/fetchSalesforceSchema.d.ts +3 -0
  181. package/dist/actions/providers/salesforce/fetchSalesforceSchema.js +40 -0
  182. package/dist/actions/providers/salesforce/generateSalesReport.js +3 -12
  183. package/dist/actions/providers/salesforce/getRecord.js +3 -12
  184. package/dist/actions/providers/salesforce/getReportMetadata.js +11 -21
  185. package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +7 -17
  186. package/dist/actions/providers/salesforce/listReports.js +3 -12
  187. package/dist/actions/providers/salesforce/searchAllSalesforceRecords.js +3 -12
  188. package/dist/actions/providers/salesforce/searchSalesforceRecords.js +3 -12
  189. package/dist/actions/providers/salesforce/updateRecord.js +3 -12
  190. package/dist/actions/providers/slack/archiveChannel.d.ts +3 -0
  191. package/dist/actions/providers/slack/archiveChannel.js +42 -0
  192. package/dist/actions/providers/slack/createChannel.js +7 -17
  193. package/dist/actions/providers/slack/getChannelMembers.js +8 -18
  194. package/dist/actions/providers/slack/getChannelMessages.js +8 -18
  195. package/dist/actions/providers/slack/helpers.js +16 -47
  196. package/dist/actions/providers/slack/messageTransformers.js +10 -13
  197. package/dist/actions/providers/slack/sendDmFromBot.js +9 -19
  198. package/dist/actions/providers/slack/sendMessage.js +7 -17
  199. package/dist/actions/providers/slackUser/searchSlack.js +179 -212
  200. package/dist/actions/providers/slackUser/searchSlackRTS.js +41 -38
  201. package/dist/actions/providers/slackUser/utils.js +1 -1
  202. package/dist/actions/providers/snowflake/auth/getSnowflakeConnection.js +23 -34
  203. package/dist/actions/providers/snowflake/getRowByFieldValue.js +4 -13
  204. package/dist/actions/providers/snowflake/runSnowflakeQuery.js +9 -19
  205. package/dist/actions/providers/zendesk/addCommentToTicket.js +5 -14
  206. package/dist/actions/providers/zendesk/assignTicket.js +3 -12
  207. package/dist/actions/providers/zendesk/createZendeskTicket.js +3 -12
  208. package/dist/actions/providers/zendesk/getTicketDetails.js +3 -12
  209. package/dist/actions/providers/zendesk/listTickets.js +3 -12
  210. package/dist/actions/providers/zendesk/searchZendeskByQuery.js +3 -12
  211. package/dist/actions/providers/zendesk/updateTicketStatus.js +3 -12
  212. package/dist/actions/util/axiosClient.js +5 -5
  213. package/dist/app.js +14 -25
  214. package/dist/utils/google.js +122 -143
  215. package/dist/utils/pdf.js +10 -21
  216. package/package.json +10 -9
@@ -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 Ajv from "ajv";
11
2
  import fs from "fs/promises";
12
3
  import yaml from "js-yaml";
@@ -70,255 +61,251 @@ z.object({
70
61
  userEmail: z.string().optional(),
71
62
  })
72
63
  `;
73
- function validateObject(object) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const ajv = new Ajv({
76
- strict: true,
77
- strictTypes: true,
78
- strictTuples: true,
79
- strictRequired: true,
80
- });
81
- // Add custom keyword - just allow it, we'll validate manually
82
- ajv.addKeyword("tags");
83
- // validate schema and check required fields
84
- const validParameters = ajv.validateSchema(object);
85
- if (!validParameters) {
86
- throw new Error(`Error validating object: ${JSON.stringify(ajv.errors, null, 4)}`);
87
- }
88
- // Handle oneOf schemas
89
- if (object.required && object.properties) {
90
- // Handle regular object schemas - check required fields
91
- for (const field of object.required) {
92
- if (!object.properties[field]) {
93
- throw new Error(`Required field ${field} is missing`);
94
- }
64
+ async function validateObject(object) {
65
+ const ajv = new Ajv({
66
+ strict: true,
67
+ strictTypes: true,
68
+ strictTuples: true,
69
+ strictRequired: true,
70
+ });
71
+ // Add custom keyword - just allow it, we'll validate manually
72
+ ajv.addKeyword("tags");
73
+ // validate schema and check required fields
74
+ const validParameters = ajv.validateSchema(object);
75
+ if (!validParameters) {
76
+ throw new Error(`Error validating object: ${JSON.stringify(ajv.errors, null, 4)}`);
77
+ }
78
+ // Handle oneOf schemas
79
+ if (object.required && object.properties) {
80
+ // Handle regular object schemas - check required fields
81
+ for (const field of object.required) {
82
+ if (!object.properties[field]) {
83
+ throw new Error(`Required field ${field} is missing`);
95
84
  }
96
85
  }
97
- // Validate tags in property schemas using Zod
98
- if (object.properties) {
99
- for (const [propName, propSchema] of Object.entries(object.properties)) {
100
- if (propSchema && typeof propSchema === "object" && "tags" in propSchema) {
101
- const tags = propSchema.tags;
102
- if (tags !== undefined) {
103
- const result = z.array(parameterTagEnum).safeParse(tags);
104
- if (!result.success) {
105
- throw new Error(`Property "${propName}" has invalid tags: ${result.error.errors.map(e => e.message).join(", ")}`);
106
- }
86
+ }
87
+ // Validate tags in property schemas using Zod
88
+ if (object.properties) {
89
+ for (const [propName, propSchema] of Object.entries(object.properties)) {
90
+ if (propSchema && typeof propSchema === "object" && "tags" in propSchema) {
91
+ const tags = propSchema.tags;
92
+ if (tags !== undefined) {
93
+ const result = z.array(parameterTagEnum).safeParse(tags);
94
+ if (!result.success) {
95
+ throw new Error(`Property "${propName}" has invalid tags: ${result.error.errors.map(e => e.message).join(", ")}`);
107
96
  }
108
97
  }
109
98
  }
110
99
  }
111
- });
100
+ }
112
101
  }
113
- function addActionTypes(_a) {
114
- return __awaiter(this, arguments, void 0, function* ({ file, prefix, action }) {
115
- // add parameter types
116
- const paramsName = `${prefix}Params`;
117
- yield addTypesToFile({
118
- file,
119
- obj: action.parameters,
120
- fallback: "z.object({})",
121
- name: paramsName,
122
- });
123
- // add output types
124
- const outputName = `${prefix}Output`;
125
- yield addTypesToFile({
126
- file,
127
- obj: action.output,
128
- fallback: "z.void()",
129
- name: outputName,
130
- });
131
- // add function type
132
- const functionName = `${prefix}Function`;
133
- file.addTypeAlias({
134
- name: functionName,
135
- type: `ActionFunction<${paramsName}Type, AuthParamsType, ${outputName}Type>`,
136
- isExported: true,
137
- });
102
+ async function addActionTypes({ file, prefix, action }) {
103
+ // add parameter types
104
+ const paramsName = `${prefix}Params`;
105
+ await addTypesToFile({
106
+ file,
107
+ obj: action.parameters,
108
+ fallback: "z.object({})",
109
+ name: paramsName,
110
+ });
111
+ // add output types
112
+ const outputName = `${prefix}Output`;
113
+ await addTypesToFile({
114
+ file,
115
+ obj: action.output,
116
+ fallback: "z.void()",
117
+ name: outputName,
118
+ });
119
+ // add function type
120
+ const functionName = `${prefix}Function`;
121
+ file.addTypeAlias({
122
+ name: functionName,
123
+ type: `ActionFunction<${paramsName}Type, AuthParamsType, ${outputName}Type>`,
124
+ isExported: true,
138
125
  });
139
126
  }
140
- function addTypesToFile(_a) {
141
- return __awaiter(this, arguments, void 0, function* ({ file, obj, fallback, name, }) {
142
- // Tool calling framework currently having trouble filling in records as opposed to objects
143
- const zodSchema = obj ? convert(obj).replace(/z\.record\(z\.any\(\)\)/g, "z.object({}).catchall(z.any())") : fallback;
144
- const zodName = `${name}Schema`;
145
- file.addVariableStatement({
146
- declarationKind: VariableDeclarationKind.Const,
147
- isExported: true,
148
- declarations: [
149
- {
150
- name: zodName,
151
- initializer: zodSchema,
152
- },
153
- ],
154
- });
155
- file.addTypeAlias({
156
- name: `${name}Type`,
157
- type: `z.infer<typeof ${zodName}>`,
158
- isExported: true,
159
- });
127
+ async function addTypesToFile({ file, obj, fallback, name, }) {
128
+ // Tool calling framework currently having trouble filling in records as opposed to objects
129
+ const zodSchema = obj ? convert(obj).replace(/z\.record\(z\.any\(\)\)/g, "z.object({}).catchall(z.any())") : fallback;
130
+ const zodName = `${name}Schema`;
131
+ file.addVariableStatement({
132
+ declarationKind: VariableDeclarationKind.Const,
133
+ isExported: true,
134
+ declarations: [
135
+ {
136
+ name: zodName,
137
+ initializer: zodSchema,
138
+ },
139
+ ],
140
+ });
141
+ file.addTypeAlias({
142
+ name: `${name}Type`,
143
+ type: `z.infer<typeof ${zodName}>`,
144
+ isExported: true,
160
145
  });
161
146
  }
162
- function generateTypes(_a) {
163
- return __awaiter(this, arguments, void 0, function* ({ inputPath = "src/actions/schema.yaml", outputPath = "src/actions/autogen/templates.ts", templatesOutputPath = "src/actions/autogen/types.ts", }) {
164
- const yamlContent = yield fs.readFile(inputPath, "utf8");
165
- const rawConfig = yaml.load(yamlContent);
166
- // Validate the config
167
- const parsedConfig = configSchema.parse(rawConfig);
168
- // Generate the TypeScript file
169
- // Initialize ts-morph project
170
- const project = new Project();
171
- const templatesFile = project.createSourceFile(outputPath, "", { overwrite: true });
172
- const typesFile = project.createSourceFile(templatesOutputPath, "", { overwrite: true });
173
- // Set the ProviderName enum based on the schema providers
174
- typesFile
175
- .addEnum({
176
- name: "ProviderName",
177
- members: Object.keys(parsedConfig.actions).map(providerName => ({
178
- name: providerName.toUpperCase().replace(/-/g, "_"),
179
- value: providerName,
180
- })),
181
- })
182
- .setIsExported(true);
183
- typesFile
184
- .addEnum({
185
- name: "ActionName",
186
- members: Array.from(new Set(Object.values(parsedConfig.actions).flatMap(provider => Object.keys(provider)))).map(actionName => ({
187
- name: actionName.toUpperCase().replace(/-/g, "_"),
188
- value: actionName,
189
- })),
190
- })
191
- .setIsExported(true);
192
- // Add imports
193
- templatesFile.addImportDeclaration({
194
- moduleSpecifier: "../../actions/parse",
195
- namedImports: ["ActionTemplate"],
196
- });
197
- typesFile.addImportDeclaration({
198
- moduleSpecifier: "zod",
199
- namedImports: ["z"],
200
- });
201
- // Initialization: set up generic ActionFunction type
202
- typesFile.addTypeAlias({
203
- name: "ActionFunction",
204
- typeParameters: ["P", "A", "O"],
205
- type: "(input: {params: P, authParams: A}) => Promise<O>",
206
- isExported: true,
207
- });
208
- // Initialization: set up authparams zod schema and type
209
- typesFile.addVariableStatement({
210
- declarationKind: VariableDeclarationKind.Const,
211
- isExported: true,
212
- declarations: [
213
- {
214
- name: "AuthParamsSchema",
215
- initializer: authParamsSchemaStr,
216
- },
217
- ],
218
- });
219
- typesFile.addTypeAlias({
220
- name: "AuthParamsType",
221
- type: "z.infer<typeof AuthParamsSchema>",
222
- isExported: true,
223
- });
224
- // ActionTag enum for action-level tags (using values defined at top of file)
225
- typesFile.addVariableStatement({
226
- declarationKind: VariableDeclarationKind.Const,
227
- isExported: true,
228
- declarations: [
229
- {
230
- name: "ActionTagSchema",
231
- initializer: `z.enum([${actionTagValues.map(t => `"${t}"`).join(", ")}])`,
232
- },
233
- ],
234
- });
235
- typesFile.addTypeAlias({
236
- name: "ActionTag",
237
- type: "z.infer<typeof ActionTagSchema>",
238
- isExported: true,
239
- });
240
- typesFile.addVariableStatement({
241
- declarationKind: VariableDeclarationKind.Const,
242
- isExported: true,
243
- declarations: [
244
- {
245
- name: "ACTION_TAGS",
246
- initializer: `[${actionTagValues.map(t => `"${t}"`).join(", ")}] as const`,
247
- },
248
- ],
249
- });
250
- // ParameterTag enum for parameter property tags (using values defined at top of file)
251
- typesFile.addVariableStatement({
252
- declarationKind: VariableDeclarationKind.Const,
253
- isExported: true,
254
- declarations: [
255
- {
256
- name: "ParameterTagSchema",
257
- initializer: `z.enum([${parameterTagValues.map(t => `"${t}"`).join(", ")}])`,
258
- },
259
- ],
260
- });
261
- typesFile.addTypeAlias({
262
- name: "ParameterTag",
263
- type: "z.infer<typeof ParameterTagSchema>",
264
- isExported: true,
265
- });
266
- typesFile.addVariableStatement({
267
- declarationKind: VariableDeclarationKind.Const,
268
- isExported: true,
269
- declarations: [
270
- {
271
- name: "PARAMETER_TAGS",
272
- initializer: `[${parameterTagValues.map(t => `"${t}"`).join(", ")}] as const`,
273
- },
274
- ],
275
- });
276
- for (const [categoryName, category] of Object.entries(parsedConfig.actions)) {
277
- for (const [actionName, action] of Object.entries(category)) {
278
- // Validate action-level tags
279
- if (action.tags && action.tags.length > 0) {
280
- const invalidTags = action.tags.filter(tag => !actionTagValues.includes(tag));
281
- if (invalidTags.length > 0) {
282
- throw new Error(`Action "${categoryName}.${actionName}" has invalid tag values: ${invalidTags.join(", ")}. Valid values are: ${actionTagValues.join(", ")}`);
283
- }
284
- }
285
- if (action.parameters) {
286
- yield validateObject(action.parameters);
287
- }
288
- if (action.output) {
289
- yield validateObject(action.output);
147
+ async function generateTypes({ inputPath = "src/actions/schema.yaml", outputPath = "src/actions/autogen/templates.ts", templatesOutputPath = "src/actions/autogen/types.ts", }) {
148
+ const yamlContent = await fs.readFile(inputPath, "utf8");
149
+ const rawConfig = yaml.load(yamlContent);
150
+ // Validate the config
151
+ const parsedConfig = configSchema.parse(rawConfig);
152
+ // Generate the TypeScript file
153
+ // Initialize ts-morph project
154
+ const project = new Project();
155
+ const templatesFile = project.createSourceFile(outputPath, "", { overwrite: true });
156
+ const typesFile = project.createSourceFile(templatesOutputPath, "", { overwrite: true });
157
+ // Set the ProviderName enum based on the schema providers
158
+ typesFile
159
+ .addEnum({
160
+ name: "ProviderName",
161
+ members: Object.keys(parsedConfig.actions).map(providerName => ({
162
+ name: providerName.toUpperCase().replace(/-/g, "_"),
163
+ value: providerName,
164
+ })),
165
+ })
166
+ .setIsExported(true);
167
+ typesFile
168
+ .addEnum({
169
+ name: "ActionName",
170
+ members: Array.from(new Set(Object.values(parsedConfig.actions).flatMap(provider => Object.keys(provider)))).map(actionName => ({
171
+ name: actionName.toUpperCase().replace(/-/g, "_"),
172
+ value: actionName,
173
+ })),
174
+ })
175
+ .setIsExported(true);
176
+ // Add imports
177
+ templatesFile.addImportDeclaration({
178
+ moduleSpecifier: "../../actions/parse",
179
+ namedImports: ["ActionTemplate"],
180
+ });
181
+ typesFile.addImportDeclaration({
182
+ moduleSpecifier: "zod",
183
+ namedImports: ["z"],
184
+ });
185
+ // Initialization: set up generic ActionFunction type
186
+ typesFile.addTypeAlias({
187
+ name: "ActionFunction",
188
+ typeParameters: ["P", "A", "O"],
189
+ type: "(input: {params: P, authParams: A}) => Promise<O>",
190
+ isExported: true,
191
+ });
192
+ // Initialization: set up authparams zod schema and type
193
+ typesFile.addVariableStatement({
194
+ declarationKind: VariableDeclarationKind.Const,
195
+ isExported: true,
196
+ declarations: [
197
+ {
198
+ name: "AuthParamsSchema",
199
+ initializer: authParamsSchemaStr,
200
+ },
201
+ ],
202
+ });
203
+ typesFile.addTypeAlias({
204
+ name: "AuthParamsType",
205
+ type: "z.infer<typeof AuthParamsSchema>",
206
+ isExported: true,
207
+ });
208
+ // ActionTag enum for action-level tags (using values defined at top of file)
209
+ typesFile.addVariableStatement({
210
+ declarationKind: VariableDeclarationKind.Const,
211
+ isExported: true,
212
+ declarations: [
213
+ {
214
+ name: "ActionTagSchema",
215
+ initializer: `z.enum([${actionTagValues.map(t => `"${t}"`).join(", ")}])`,
216
+ },
217
+ ],
218
+ });
219
+ typesFile.addTypeAlias({
220
+ name: "ActionTag",
221
+ type: "z.infer<typeof ActionTagSchema>",
222
+ isExported: true,
223
+ });
224
+ typesFile.addVariableStatement({
225
+ declarationKind: VariableDeclarationKind.Const,
226
+ isExported: true,
227
+ declarations: [
228
+ {
229
+ name: "ACTION_TAGS",
230
+ initializer: `[${actionTagValues.map(t => `"${t}"`).join(", ")}] as const`,
231
+ },
232
+ ],
233
+ });
234
+ // ParameterTag enum for parameter property tags (using values defined at top of file)
235
+ typesFile.addVariableStatement({
236
+ declarationKind: VariableDeclarationKind.Const,
237
+ isExported: true,
238
+ declarations: [
239
+ {
240
+ name: "ParameterTagSchema",
241
+ initializer: `z.enum([${parameterTagValues.map(t => `"${t}"`).join(", ")}])`,
242
+ },
243
+ ],
244
+ });
245
+ typesFile.addTypeAlias({
246
+ name: "ParameterTag",
247
+ type: "z.infer<typeof ParameterTagSchema>",
248
+ isExported: true,
249
+ });
250
+ typesFile.addVariableStatement({
251
+ declarationKind: VariableDeclarationKind.Const,
252
+ isExported: true,
253
+ declarations: [
254
+ {
255
+ name: "PARAMETER_TAGS",
256
+ initializer: `[${parameterTagValues.map(t => `"${t}"`).join(", ")}] as const`,
257
+ },
258
+ ],
259
+ });
260
+ for (const [categoryName, category] of Object.entries(parsedConfig.actions)) {
261
+ for (const [actionName, action] of Object.entries(category)) {
262
+ // Validate action-level tags
263
+ if (action.tags && action.tags.length > 0) {
264
+ const invalidTags = action.tags.filter(tag => !actionTagValues.includes(tag));
265
+ if (invalidTags.length > 0) {
266
+ throw new Error(`Action "${categoryName}.${actionName}" has invalid tag values: ${invalidTags.join(", ")}. Valid values are: ${actionTagValues.join(", ")}`);
290
267
  }
291
- const actionPrefix = `${categoryName}${snakeToPascal(actionName)}`;
292
- const constName = `${actionPrefix}Definition`;
293
- // Convert the action definition to a string representation
294
- const templateObj = Object.assign({ provider: categoryName, name: actionName }, action);
295
- // Validate the template object
296
- const template = actionTemplateSchema.parse(templateObj);
297
- // Add the constant declaration
298
- const templateStr = JSON.stringify(template, null, 4);
299
- templatesFile.addVariableStatement({
300
- declarationKind: VariableDeclarationKind.Const,
301
- isExported: true,
302
- declarations: [
303
- {
304
- name: constName,
305
- type: "ActionTemplate",
306
- initializer: templateStr,
307
- },
308
- ],
309
- });
310
- // parameter types
311
- yield addActionTypes({
312
- file: typesFile,
313
- prefix: actionPrefix,
314
- action,
315
- });
316
268
  }
269
+ if (action.parameters) {
270
+ await validateObject(action.parameters);
271
+ }
272
+ if (action.output) {
273
+ await validateObject(action.output);
274
+ }
275
+ const actionPrefix = `${categoryName}${snakeToPascal(actionName)}`;
276
+ const constName = `${actionPrefix}Definition`;
277
+ // Convert the action definition to a string representation
278
+ const templateObj = {
279
+ provider: categoryName,
280
+ name: actionName,
281
+ ...action,
282
+ };
283
+ // Validate the template object
284
+ const template = actionTemplateSchema.parse(templateObj);
285
+ // Add the constant declaration
286
+ const templateStr = JSON.stringify(template, null, 4);
287
+ templatesFile.addVariableStatement({
288
+ declarationKind: VariableDeclarationKind.Const,
289
+ isExported: true,
290
+ declarations: [
291
+ {
292
+ name: constName,
293
+ type: "ActionTemplate",
294
+ initializer: templateStr,
295
+ },
296
+ ],
297
+ });
298
+ // parameter types
299
+ await addActionTypes({
300
+ file: typesFile,
301
+ prefix: actionPrefix,
302
+ action,
303
+ });
317
304
  }
318
- // Save the generated TypeScript file
319
- yield templatesFile.save();
320
- yield typesFile.save();
321
- });
305
+ }
306
+ // Save the generated TypeScript file
307
+ await templatesFile.save();
308
+ await typesFile.save();
322
309
  }
323
310
  generateTypes({}).catch(error => {
324
311
  console.error("Error generating types:", error);
@@ -1,29 +1,22 @@
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 commentAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
13
- var _b, _c;
3
+ const commentAsanaTask = async ({ params, authParams, }) => {
14
4
  const { authToken } = authParams;
15
5
  const { commentText, isPinned, taskId } = params;
16
6
  if (!authToken) {
17
7
  return { success: false, error: MISSING_AUTH_TOKEN };
18
8
  }
19
9
  try {
20
- const response = yield axiosClient.post(`https://app.asana.com/api/1.0/tasks/${taskId}/stories`, {
21
- data: Object.assign({ text: commentText }, (isPinned !== undefined && { is_pinned: isPinned })),
10
+ const response = await axiosClient.post(`https://app.asana.com/api/1.0/tasks/${taskId}/stories`, {
11
+ data: {
12
+ text: commentText,
13
+ ...(isPinned !== undefined && { is_pinned: isPinned }),
14
+ },
22
15
  }, {
23
16
  headers: { Authorization: `Bearer ${authToken}` },
24
17
  });
25
18
  // Validate response
26
- const commentGid = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.gid;
19
+ const commentGid = response?.data?.data?.gid;
27
20
  if (!commentGid) {
28
21
  throw new Error("Failed to create task: No valid comment ID returned from Asana");
29
22
  }
@@ -39,5 +32,5 @@ const commentAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
39
32
  error: error instanceof Error ? error.message : "Unknown error",
40
33
  };
41
34
  }
42
- });
35
+ };
43
36
  export default commentAsanaTask;
@@ -1,19 +1,10 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { axiosClient } from "../../util/axiosClient.js";
11
2
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
3
  import { getWorkspaceIdFromProject, getUserIdByEmail } from "./utils.js";
13
- const getTaskTemplates = (authToken, projectId) => __awaiter(void 0, void 0, void 0, function* () {
4
+ const getTaskTemplates = async (authToken, projectId) => {
14
5
  const url = `https://app.asana.com/api/1.0/task_templates/?project=${projectId}`;
15
6
  try {
16
- const response = yield axiosClient.get(url, {
7
+ const response = await axiosClient.get(url, {
17
8
  headers: { Authorization: `Bearer ${authToken}` },
18
9
  });
19
10
  return response.data.data;
@@ -22,21 +13,20 @@ const getTaskTemplates = (authToken, projectId) => __awaiter(void 0, void 0, voi
22
13
  console.error("Error fetching Asana task templates:", error);
23
14
  return [];
24
15
  }
25
- });
26
- const createAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
27
- var _b, _c;
16
+ };
17
+ const createAsanaTask = async ({ params, authParams, }) => {
28
18
  const { authToken } = authParams;
29
19
  const { name, projectId, description, customFields, taskTemplate, assignee, approvalStatus, dueAt } = params;
30
20
  if (!authToken) {
31
21
  return { success: false, error: MISSING_AUTH_TOKEN };
32
22
  }
33
- const workspaceId = yield getWorkspaceIdFromProject(projectId, authToken);
23
+ const workspaceId = await getWorkspaceIdFromProject(projectId, authToken);
34
24
  if (!workspaceId) {
35
25
  return { success: false, error: "Project ID invalid: unable to get workspaceID" };
36
26
  }
37
27
  let assigneeId;
38
28
  if (assignee && assignee.includes("@")) {
39
- assigneeId = yield getUserIdByEmail(authToken, workspaceId, assignee);
29
+ assigneeId = await getUserIdByEmail(authToken, workspaceId, assignee);
40
30
  }
41
31
  else {
42
32
  assigneeId = assignee;
@@ -44,7 +34,7 @@ const createAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
44
34
  let templateId = null;
45
35
  try {
46
36
  if (taskTemplate) {
47
- const templates = yield getTaskTemplates(authToken, projectId);
37
+ const templates = await getTaskTemplates(authToken, projectId);
48
38
  if (/^\d+$/.test(taskTemplate)) {
49
39
  // Numeric: try ID match
50
40
  if (templates.some((t) => t.gid === taskTemplate)) {
@@ -66,13 +56,22 @@ const createAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
66
56
  };
67
57
  }
68
58
  }
69
- const response = yield axiosClient.post(`https://app.asana.com/api/1.0/tasks`, {
70
- data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ name, projects: [projectId] }, (description && { notes: description })), (customFields && { custom_fields: customFields })), (templateId && { task_template: templateId })), (assigneeId && { assignee: assigneeId })), (approvalStatus && { approval_status: approvalStatus })), (dueAt && { due_at: dueAt })),
59
+ const response = await axiosClient.post(`https://app.asana.com/api/1.0/tasks`, {
60
+ data: {
61
+ name,
62
+ projects: [projectId],
63
+ ...(description && { notes: description }),
64
+ ...(customFields && { custom_fields: customFields }),
65
+ ...(templateId && { task_template: templateId }),
66
+ ...(assigneeId && { assignee: assigneeId }),
67
+ ...(approvalStatus && { approval_status: approvalStatus }),
68
+ ...(dueAt && { due_at: dueAt }),
69
+ },
71
70
  }, {
72
71
  headers: { Authorization: `Bearer ${authToken}` },
73
72
  });
74
73
  // Validate response
75
- const taskGid = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.gid;
74
+ const taskGid = response?.data?.data?.gid;
76
75
  if (!taskGid) {
77
76
  throw new Error("Failed to create task: No valid task ID returned from Asana");
78
77
  }
@@ -88,5 +87,5 @@ const createAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ par
88
87
  error: error instanceof Error ? error.message : "Unknown error",
89
88
  };
90
89
  }
91
- });
90
+ };
92
91
  export default createAsanaTask;