@credal/actions 0.1.31 → 0.1.34

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 (112) hide show
  1. package/dist/actions/actionMapper.js +238 -0
  2. package/dist/actions/autogen/definitions.d.ts +5 -0
  3. package/dist/actions/autogen/definitions.js +132 -0
  4. package/dist/actions/autogen/templates.d.ts +38 -0
  5. package/dist/actions/autogen/templates.js +4570 -178
  6. package/dist/actions/autogen/types.d.ts +1414 -33
  7. package/dist/actions/autogen/types.js +1812 -1
  8. package/dist/actions/definitions.js +35 -0
  9. package/dist/actions/groups.js +44 -4
  10. package/dist/actions/invoke.js +3 -0
  11. package/dist/actions/invokeMapper.d.ts +9 -0
  12. package/dist/actions/invokeMapper.js +33 -0
  13. package/dist/actions/parse.js +3 -0
  14. package/dist/actions/providers/asana/commentAsanaTask.d.ts +3 -0
  15. package/dist/actions/providers/asana/commentAsanaTask.js +44 -0
  16. package/dist/actions/providers/asana/createAsanaTask.d.ts +3 -0
  17. package/dist/actions/providers/asana/createAsanaTask.js +93 -0
  18. package/dist/actions/providers/asana/updateAsanaTask.d.ts +3 -0
  19. package/dist/actions/providers/asana/updateAsanaTask.js +50 -0
  20. package/dist/actions/providers/asana/utils.d.ts +6 -0
  21. package/dist/actions/providers/asana/utils.js +73 -0
  22. package/dist/actions/providers/ashby/addCandidateToProject.d.ts +3 -0
  23. package/dist/actions/providers/ashby/addCandidateToProject.js +32 -0
  24. package/dist/actions/providers/ashby/createCandidate.d.ts +3 -0
  25. package/dist/actions/providers/ashby/createCandidate.js +42 -0
  26. package/dist/actions/providers/ashby/createNote.d.ts +3 -0
  27. package/dist/actions/providers/ashby/createNote.js +32 -0
  28. package/dist/actions/providers/ashby/getCandidateInfo.d.ts +3 -0
  29. package/dist/actions/providers/ashby/getCandidateInfo.js +34 -0
  30. package/dist/actions/providers/ashby/listCandidateNotes.d.ts +3 -0
  31. package/dist/actions/providers/ashby/listCandidateNotes.js +34 -0
  32. package/dist/actions/providers/ashby/listCandidates.d.ts +3 -0
  33. package/dist/actions/providers/ashby/listCandidates.js +31 -0
  34. package/dist/actions/providers/ashby/searchCandidates.d.ts +3 -0
  35. package/dist/actions/providers/ashby/searchCandidates.js +35 -0
  36. package/dist/actions/providers/ashby/updateCandidate.d.ts +3 -0
  37. package/dist/actions/providers/ashby/updateCandidate.js +60 -0
  38. package/dist/actions/providers/confluence/updatePage.js +2 -5
  39. package/dist/actions/providers/github/createBranch.d.ts +6 -0
  40. package/dist/actions/providers/github/createBranch.js +68 -0
  41. package/dist/actions/providers/github/createOrUpdateFile.d.ts +6 -0
  42. package/dist/actions/providers/github/createOrUpdateFile.js +75 -0
  43. package/dist/actions/providers/github/createPullRequest.d.ts +6 -0
  44. package/dist/actions/providers/github/createPullRequest.js +48 -0
  45. package/dist/actions/providers/google-oauth/createPresentation.d.ts +6 -0
  46. package/dist/actions/providers/google-oauth/createPresentation.js +52 -0
  47. package/dist/actions/providers/google-oauth/createSpreadsheet.d.ts +6 -0
  48. package/dist/actions/providers/google-oauth/createSpreadsheet.js +62 -0
  49. package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.d.ts +6 -0
  50. package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +74 -0
  51. package/dist/actions/providers/google-oauth/updateDoc.d.ts +7 -0
  52. package/dist/actions/providers/google-oauth/updateDoc.js +69 -0
  53. package/dist/actions/providers/google-oauth/updatePresentation.d.ts +7 -0
  54. package/dist/actions/providers/google-oauth/updatePresentation.js +64 -0
  55. package/dist/actions/providers/google-oauth/updateSpreadsheet.d.ts +7 -0
  56. package/dist/actions/providers/google-oauth/updateSpreadsheet.js +51 -0
  57. package/dist/actions/providers/googlemaps/nearbysearch.js +31 -31
  58. package/dist/actions/providers/jira/assignJiraTicket.d.ts +3 -0
  59. package/dist/actions/providers/jira/assignJiraTicket.js +52 -0
  60. package/dist/actions/providers/jira/commentJiraTicket.d.ts +3 -0
  61. package/dist/actions/providers/jira/commentJiraTicket.js +56 -0
  62. package/dist/actions/providers/jira/createJiraTicket.js +3 -24
  63. package/dist/actions/providers/jira/createTicket.d.ts +3 -0
  64. package/dist/actions/providers/jira/createTicket.js +34 -0
  65. package/dist/actions/providers/jira/getJiraTicketDetails.d.ts +3 -0
  66. package/dist/actions/providers/jira/getJiraTicketDetails.js +40 -0
  67. package/dist/actions/providers/jira/getJiraTicketHistory.d.ts +3 -0
  68. package/dist/actions/providers/jira/getJiraTicketHistory.js +41 -0
  69. package/dist/actions/providers/jira/updateJiraTicketDetails.d.ts +3 -0
  70. package/dist/actions/providers/jira/updateJiraTicketDetails.js +56 -0
  71. package/dist/actions/providers/jira/updateJiraTicketStatus.d.ts +3 -0
  72. package/dist/actions/providers/jira/updateJiraTicketStatus.js +57 -0
  73. package/dist/actions/providers/jira/utils.d.ts +1 -0
  74. package/dist/actions/providers/jira/utils.js +34 -0
  75. package/dist/actions/providers/microsoft/messageTeamsChannel.d.ts +3 -0
  76. package/dist/actions/providers/microsoft/messageTeamsChannel.js +45 -0
  77. package/dist/actions/providers/microsoft/messageTeamsChat.d.ts +3 -0
  78. package/dist/actions/providers/microsoft/messageTeamsChat.js +42 -0
  79. package/dist/actions/providers/microsoft/utils.d.ts +4 -0
  80. package/dist/actions/providers/microsoft/utils.js +55 -0
  81. package/dist/actions/providers/salesforce/createCase.d.ts +3 -0
  82. package/dist/actions/providers/salesforce/createCase.js +44 -0
  83. package/dist/actions/providers/salesforce/generateSalesReport.d.ts +3 -0
  84. package/dist/actions/providers/salesforce/generateSalesReport.js +52 -0
  85. package/dist/actions/providers/salesforce/getRecord.d.ts +3 -0
  86. package/dist/actions/providers/salesforce/getRecord.js +42 -0
  87. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +3 -0
  88. package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +43 -0
  89. package/dist/actions/providers/salesforce/updateRecord.d.ts +3 -0
  90. package/dist/actions/providers/salesforce/updateRecord.js +42 -0
  91. package/dist/actions/providers/slack/getChannelMessages.d.ts +3 -0
  92. package/dist/actions/providers/slack/getChannelMessages.js +33 -0
  93. package/dist/actions/providers/slack/list_conversations.d.ts +3 -0
  94. package/dist/actions/providers/slack/list_conversations.js +60 -0
  95. package/dist/actions/providers/slack/summarizeChannel.d.ts +3 -0
  96. package/dist/actions/providers/slack/summarizeChannel.js +51 -0
  97. package/dist/actions/providers/zendesk/addCommentToTicket.d.ts +3 -0
  98. package/dist/actions/providers/zendesk/addCommentToTicket.js +37 -0
  99. package/dist/actions/providers/zendesk/assignTicket.d.ts +3 -0
  100. package/dist/actions/providers/zendesk/assignTicket.js +37 -0
  101. package/dist/actions/providers/zendesk/getTicketDetails.d.ts +3 -0
  102. package/dist/actions/providers/zendesk/getTicketDetails.js +35 -0
  103. package/dist/actions/providers/zendesk/updateTicketStatus.d.ts +3 -0
  104. package/dist/actions/providers/zendesk/updateTicketStatus.js +37 -0
  105. package/dist/actions/schema.js +6 -0
  106. package/dist/actions/types.js +2 -0
  107. package/dist/main.js +11 -0
  108. package/package.json +7 -1
  109. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +0 -3
  110. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.js +0 -154
  111. package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +0 -3
  112. package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +0 -45
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mathAddDefinition = exports.slackSendMessageDefinition = void 0;
4
+ exports.slackSendMessageDefinition = {
5
+ name: "send_message",
6
+ description: "Sends a message to a Slack channel",
7
+ parameters: {
8
+ "channel": {
9
+ "type": "string",
10
+ "description": "The Slack channel to send the message to (e.g., \\#general, \\#alerts)",
11
+ "required": true
12
+ },
13
+ "message": {
14
+ "type": "string",
15
+ "description": "The message content to send to Slack. Can include markdown formatting.",
16
+ "required": true
17
+ }
18
+ }
19
+ };
20
+ exports.mathAddDefinition = {
21
+ name: "add",
22
+ description: "Adds two numbers together",
23
+ parameters: {
24
+ "a": {
25
+ "type": "number",
26
+ "description": "The first number to add",
27
+ "required": true
28
+ },
29
+ "b": {
30
+ "type": "number",
31
+ "description": "The second number to add",
32
+ "required": true
33
+ }
34
+ }
35
+ };
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ACTION_GROUPS = void 0;
4
4
  const templates_1 = require("../actions/autogen/templates");
5
5
  exports.ACTION_GROUPS = {
6
+ ASANA: {
7
+ description: "Actions for interacting with Asana",
8
+ actions: [templates_1.asanaCommentTaskDefinition, templates_1.asanaCreateTaskDefinition, templates_1.asanaUpdateTaskDefinition],
9
+ },
6
10
  SLACK_LIST_CONVERSATIONS: {
7
11
  description: "Actions for interacting with Slack",
8
12
  actions: [templates_1.slackListConversationsDefinition, templates_1.slackSendMessageDefinition],
@@ -21,7 +25,18 @@ exports.ACTION_GROUPS = {
21
25
  },
22
26
  GOOGLE_DRIVE: {
23
27
  description: "Action for interacting with Google Drive",
24
- actions: [templates_1.googleOauthCreateNewGoogleDocDefinition],
28
+ actions: [
29
+ templates_1.googleOauthCreateNewGoogleDocDefinition,
30
+ templates_1.googleOauthUpdateDocDefinition,
31
+ templates_1.googleOauthCreateSpreadsheetDefinition,
32
+ templates_1.googleOauthUpdateSpreadsheetDefinition,
33
+ templates_1.googleOauthCreatePresentationDefinition,
34
+ templates_1.googleOauthUpdatePresentationDefinition,
35
+ ],
36
+ },
37
+ GOOGLE_CALENDAR: {
38
+ description: "Actions for interacting with Google Calendar",
39
+ actions: [templates_1.googleOauthScheduleCalendarMeetingDefinition],
25
40
  },
26
41
  CREDAL_CALL_COPILOT: {
27
42
  description: "Action for calling a Credal Copilot",
@@ -43,9 +58,17 @@ exports.ACTION_GROUPS = {
43
58
  description: "Action for getting content from a Snowflake table",
44
59
  actions: [templates_1.snowflakeGetRowByFieldValueDefinition, templates_1.snowflakeRunSnowflakeQueryDefinition],
45
60
  },
46
- JIRA_CREATE_TICKET: {
47
- description: "Action for creating a Jira ticket",
48
- actions: [templates_1.jiraCreateJiraTicketDefinition],
61
+ JIRA_ACTIONS: {
62
+ description: "Action for interacting with Jira tickets",
63
+ actions: [
64
+ templates_1.jiraAssignJiraTicketDefinition,
65
+ templates_1.jiraCreateJiraTicketDefinition,
66
+ templates_1.jiraCommentJiraTicketDefinition,
67
+ templates_1.jiraGetJiraTicketDetailsDefinition,
68
+ templates_1.jiraGetJiraTicketHistoryDefinition,
69
+ templates_1.jiraUpdateJiraTicketDetailsDefinition,
70
+ templates_1.jiraUpdateJiraTicketStatusDefinition,
71
+ ],
49
72
  },
50
73
  OPENSTREETMAP_GET_LATITUDE_LONGITUDE_FROM_LOCATION: {
51
74
  description: "Action for getting the latitude and longitude of a location",
@@ -75,4 +98,21 @@ exports.ACTION_GROUPS = {
75
98
  description: "Actions for interacting with Looker",
76
99
  actions: [templates_1.lookerEnableUserByEmailDefinition],
77
100
  },
101
+ SALESFORCE: {
102
+ description: "Actions for interacting with Salesforce",
103
+ actions: [
104
+ templates_1.salesforceUpdateRecordDefinition,
105
+ templates_1.salesforceCreateCaseDefinition,
106
+ templates_1.salesforceGenerateSalesReportDefinition,
107
+ templates_1.salesforceGetRecordDefinition,
108
+ ],
109
+ },
110
+ MICROSOFT: {
111
+ description: "Actions for interacting with Microsoft 365",
112
+ actions: [templates_1.microsoftMessageTeamsChatDefinition, templates_1.microsoftMessageTeamsChannelDefinition],
113
+ },
114
+ GITHUB: {
115
+ description: "Actions for interacting with GitHub",
116
+ actions: [templates_1.githubCreateOrUpdateFileDefinition, templates_1.githubCreateBranchDefinition, templates_1.githubCreatePullRequestDefinition],
117
+ },
78
118
  };
@@ -14,6 +14,9 @@ const actionMapper_1 = require("./actionMapper");
14
14
  function invokeAction(input) {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
16
  const { provider, name, parameters, authParams } = input;
17
+ if (!actionMapper_1.ActionMapper[provider]) {
18
+ throw new Error(`Provider '${provider}' not found`);
19
+ }
17
20
  const providerFunction = actionMapper_1.ActionMapper[provider][name].fn;
18
21
  return providerFunction({ params: parameters, authParams });
19
22
  });
@@ -0,0 +1,9 @@
1
+ import { type ActionFunction } from "./autogen/types";
2
+ import { z } from "zod";
3
+ interface ActionFunctionComponents {
4
+ fn: ActionFunction<any, any, any>;
5
+ paramsSchema: z.ZodSchema;
6
+ outputSchema: z.ZodSchema;
7
+ }
8
+ export declare const FunctionMapper: Record<string, Record<string, ActionFunctionComponents>>;
9
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FunctionMapper = void 0;
7
+ const add_1 = __importDefault(require("./providers/math/add"));
8
+ const list_conversations_1 = __importDefault(require("./providers/slack/list_conversations"));
9
+ const updatePage_1 = __importDefault(require("./providers/confluence/updatePage"));
10
+ const types_1 = require("./autogen/types");
11
+ exports.FunctionMapper = {
12
+ math: {
13
+ add: {
14
+ fn: add_1.default,
15
+ paramsSchema: types_1.mathAddParamsSchema,
16
+ outputSchema: types_1.mathAddOutputSchema,
17
+ },
18
+ },
19
+ slack: {
20
+ listConversations: {
21
+ fn: list_conversations_1.default,
22
+ paramsSchema: types_1.slackListConversationsParamsSchema,
23
+ outputSchema: types_1.slackListConversationsOutputSchema,
24
+ },
25
+ },
26
+ confluence: {
27
+ updatePage: {
28
+ fn: updatePage_1.default,
29
+ paramsSchema: types_1.confluenceUpdatePageParamsSchema,
30
+ outputSchema: types_1.confluenceUpdatePageOutputSchema,
31
+ },
32
+ },
33
+ };
@@ -55,6 +55,9 @@ z.object({
55
55
  awsSecretAccessKey: z.string().optional(),
56
56
  clientId: z.string().optional(),
57
57
  clientSecret: z.string().optional(),
58
+ tenantId: z.string().optional(),
59
+ refreshToken: z.string().optional(),
60
+ redirectUri: z.string().optional(),
58
61
  })
59
62
  `;
60
63
  function validateObject(object) {
@@ -0,0 +1,3 @@
1
+ import { asanaCommentTaskFunction } from "../../autogen/types";
2
+ declare const commentAsanaTask: asanaCommentTaskFunction;
3
+ export default commentAsanaTask;
@@ -0,0 +1,44 @@
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 commentAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ var _b, _c;
15
+ const { authToken } = authParams;
16
+ const { commentText, isPinned, taskId } = params;
17
+ if (!commentText || !authToken) {
18
+ return { success: false, error: "Comment text and valid authToken are required" };
19
+ }
20
+ try {
21
+ const response = yield axiosClient_1.axiosClient.post(`https://app.asana.com/api/1.0/tasks/${taskId}/stories`, {
22
+ data: Object.assign({ text: commentText }, (isPinned !== undefined && { is_pinned: isPinned })),
23
+ }, {
24
+ headers: { Authorization: `Bearer ${authToken}` },
25
+ });
26
+ // Validate response
27
+ 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;
28
+ if (!commentGid) {
29
+ throw new Error("Failed to create task: No valid comment ID returned from Asana");
30
+ }
31
+ return {
32
+ success: true,
33
+ commentUrl: `https://app.asana.com/0/0/${taskId}/${commentGid}/f`,
34
+ };
35
+ }
36
+ catch (error) {
37
+ console.error("Error creating Asana task:", error);
38
+ return {
39
+ success: false,
40
+ error: error instanceof Error ? error.message : "Unknown error",
41
+ };
42
+ }
43
+ });
44
+ exports.default = commentAsanaTask;
@@ -0,0 +1,3 @@
1
+ import { asanaCreateTaskFunction } from "../../autogen/types";
2
+ declare const createAsanaTask: asanaCreateTaskFunction;
3
+ export default createAsanaTask;
@@ -0,0 +1,93 @@
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 utils_1 = require("./utils");
14
+ const getTaskTemplates = (authToken, projectId) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const url = `https://app.asana.com/api/1.0/task_templates/?project=${projectId}`;
16
+ try {
17
+ const response = yield axiosClient_1.axiosClient.get(url, {
18
+ headers: { Authorization: `Bearer ${authToken}` },
19
+ });
20
+ return response.data.data;
21
+ }
22
+ catch (error) {
23
+ console.error("Error fetching Asana task templates:", error);
24
+ return [];
25
+ }
26
+ });
27
+ const createAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
28
+ var _b, _c;
29
+ const { authToken } = authParams;
30
+ const { name, projectId, description, customFields, taskTemplate, assignee, approvalStatus, dueAt } = params;
31
+ if (!name || !authToken || !projectId) {
32
+ return { success: false, error: "Task name, valid authToken, and projectId are required" };
33
+ }
34
+ const workspaceId = yield (0, utils_1.getWorkspaceIdFromProject)(projectId, authToken);
35
+ if (!workspaceId) {
36
+ return { success: false, error: "Project ID invalid: unable to get workspaceID" };
37
+ }
38
+ let assigneeId;
39
+ if (assignee && assignee.includes("@")) {
40
+ assigneeId = yield (0, utils_1.getUserIdByEmail)(authToken, workspaceId, assignee);
41
+ }
42
+ else {
43
+ assigneeId = assignee;
44
+ }
45
+ let templateId = null;
46
+ try {
47
+ if (taskTemplate) {
48
+ const templates = yield getTaskTemplates(authToken, projectId);
49
+ if (/^\d+$/.test(taskTemplate)) {
50
+ // Numeric: try ID match
51
+ if (templates.some((t) => t.gid === taskTemplate)) {
52
+ templateId = taskTemplate;
53
+ }
54
+ }
55
+ else {
56
+ // Try to find a template by name
57
+ const taskTemplateStr = taskTemplate.trim().toLowerCase();
58
+ const matchedTemplate = templates.find((t) => t.name.toLowerCase() === taskTemplateStr);
59
+ if (matchedTemplate) {
60
+ templateId = matchedTemplate.gid;
61
+ }
62
+ }
63
+ if (!templateId) {
64
+ return {
65
+ success: false,
66
+ error: `Task template '${taskTemplate}' not found. Available templates: ${templates.map((t) => t.name).join(", ")}`,
67
+ };
68
+ }
69
+ }
70
+ const response = yield axiosClient_1.axiosClient.post(`https://app.asana.com/api/1.0/tasks`, {
71
+ 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 })),
72
+ }, {
73
+ headers: { Authorization: `Bearer ${authToken}` },
74
+ });
75
+ // Validate response
76
+ 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;
77
+ if (!taskGid) {
78
+ throw new Error("Failed to create task: No valid task ID returned from Asana");
79
+ }
80
+ return {
81
+ success: true,
82
+ taskUrl: `https://app.asana.com/0/${projectId}/${taskGid}`,
83
+ };
84
+ }
85
+ catch (error) {
86
+ console.error("Error creating Asana task:", error);
87
+ return {
88
+ success: false,
89
+ error: error instanceof Error ? error.message : "Unknown error",
90
+ };
91
+ }
92
+ });
93
+ exports.default = createAsanaTask;
@@ -0,0 +1,3 @@
1
+ import { asanaUpdateTaskFunction } from "../../autogen/types";
2
+ declare const updateAsanaTask: asanaUpdateTaskFunction;
3
+ export default updateAsanaTask;
@@ -0,0 +1,50 @@
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 utils_1 = require("./utils");
14
+ const updateAsanaTask = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
15
+ const { authToken } = authParams;
16
+ const { name, taskId, description, customFields, completed, assignee, approvalStatus, dueAt } = params;
17
+ if (!authToken || !taskId) {
18
+ return { success: false, error: "Valid authToken, and taskId are required" };
19
+ }
20
+ const { workspaceId, permalinkUrl } = yield (0, utils_1.getWorkspaceIdAndPermalinkFromTask)(taskId, authToken);
21
+ if (!workspaceId || !permalinkUrl) {
22
+ return { success: false, error: "Task ID invalid: unable to get workspaceID or permalink" };
23
+ }
24
+ let assigneeId;
25
+ if (assignee && assignee.includes("@")) {
26
+ assigneeId = yield (0, utils_1.getUserIdByEmail)(authToken, workspaceId, assignee);
27
+ }
28
+ else {
29
+ assigneeId = assignee;
30
+ }
31
+ try {
32
+ yield axiosClient_1.axiosClient.put(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
33
+ 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 })),
34
+ }, {
35
+ headers: { Authorization: `Bearer ${authToken}` },
36
+ });
37
+ return {
38
+ success: true,
39
+ taskUrl: permalinkUrl,
40
+ };
41
+ }
42
+ catch (error) {
43
+ console.error("Error updating Asana task:", error);
44
+ return {
45
+ success: false,
46
+ error: error instanceof Error ? error.message : "Unknown error",
47
+ };
48
+ }
49
+ });
50
+ exports.default = updateAsanaTask;
@@ -0,0 +1,6 @@
1
+ export declare function getWorkspaceIdFromProject(projectId: string, authToken: string): Promise<string | null>;
2
+ export declare function getWorkspaceIdAndPermalinkFromTask(taskId: string, authToken: string): Promise<{
3
+ workspaceId: string | null;
4
+ permalinkUrl: string | null;
5
+ }>;
6
+ export declare function getUserIdByEmail(authToken: string, workspaceId: string, email: string): Promise<any>;
@@ -0,0 +1,73 @@
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
+ exports.getWorkspaceIdFromProject = getWorkspaceIdFromProject;
13
+ exports.getWorkspaceIdAndPermalinkFromTask = getWorkspaceIdAndPermalinkFromTask;
14
+ exports.getUserIdByEmail = getUserIdByEmail;
15
+ const axiosClient_1 = require("../../util/axiosClient");
16
+ function getWorkspaceIdFromProject(projectId, authToken) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ var _a, _b, _c;
19
+ if (!projectId || !authToken) {
20
+ console.error("Project ID and authToken are required");
21
+ return null;
22
+ }
23
+ try {
24
+ const response = yield axiosClient_1.axiosClient.get(`https://app.asana.com/api/1.0/projects/${projectId}`, {
25
+ headers: { Authorization: `Bearer ${authToken}` },
26
+ });
27
+ 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;
28
+ }
29
+ catch (error) {
30
+ console.error("Error fetching workspace ID from project:", error);
31
+ return null;
32
+ }
33
+ });
34
+ }
35
+ function getWorkspaceIdAndPermalinkFromTask(taskId, authToken) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ var _a, _b, _c, _d, _e;
38
+ if (!taskId || !authToken) {
39
+ console.error("Task ID and authToken are required");
40
+ return { workspaceId: null, permalinkUrl: null };
41
+ }
42
+ try {
43
+ const response = yield axiosClient_1.axiosClient.get(`https://app.asana.com/api/1.0/tasks/${taskId}`, {
44
+ headers: { Authorization: `Bearer ${authToken}` },
45
+ });
46
+ 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;
47
+ 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
48
+ return { workspaceId, permalinkUrl };
49
+ }
50
+ catch (error) {
51
+ console.error("Error fetching workspace ID and permalink URL from task:", error);
52
+ return { workspaceId: null, permalinkUrl: null };
53
+ }
54
+ });
55
+ }
56
+ function getUserIdByEmail(authToken, workspaceId, email) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ // Get all users in the workspace
59
+ const url = `https://app.asana.com/api/1.0/workspaces/${workspaceId}/users?opt_fields=email,name,gid`;
60
+ try {
61
+ const response = yield axiosClient_1.axiosClient.get(url, {
62
+ headers: { Authorization: `Bearer ${authToken}` },
63
+ });
64
+ // Filter the users by email on the client side
65
+ const matchingUser = response.data.data.find((user) => user.email && user.email.toLowerCase() === email.toLowerCase());
66
+ return matchingUser ? matchingUser.gid : null;
67
+ }
68
+ catch (error) {
69
+ console.error("Error fetching users:", error);
70
+ return null;
71
+ }
72
+ });
73
+ }
@@ -0,0 +1,3 @@
1
+ import { ashbyAddCandidateToProjectFunction } from "../../autogen/types";
2
+ declare const addCandidateToProject: ashbyAddCandidateToProjectFunction;
3
+ export default addCandidateToProject;
@@ -0,0 +1,32 @@
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 addCandidateToProject = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ const { candidateId, projectId } = params;
15
+ const { authToken } = authParams;
16
+ if (!authToken) {
17
+ throw new Error("Auth token is required");
18
+ }
19
+ const response = yield axiosClient_1.axiosClient.post(`https://api.ashbyhq.com/candidate.addProject`, {
20
+ candidateId,
21
+ projectId,
22
+ }, {
23
+ auth: {
24
+ username: authToken,
25
+ password: "",
26
+ },
27
+ });
28
+ if (!response.data.success) {
29
+ throw new Error(response.data.errors.join("; "));
30
+ }
31
+ });
32
+ exports.default = addCandidateToProject;
@@ -0,0 +1,3 @@
1
+ import { ashbyCreateCandidateFunction } from "../../autogen/types";
2
+ declare const createCandidate: ashbyCreateCandidateFunction;
3
+ export default createCandidate;
@@ -0,0 +1,42 @@
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 createCandidate = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ const { authToken } = authParams;
15
+ if (!authToken) {
16
+ throw new Error("Auth token is required");
17
+ }
18
+ if (!params.name) {
19
+ throw new Error("Name is required");
20
+ }
21
+ const response = yield axiosClient_1.axiosClient.post(`https://api.ashbyhq.com/candidate.create`, {
22
+ name: params.name,
23
+ email: params.email,
24
+ phoneNumber: params.phoneNumber,
25
+ linkedInUrl: params.linkedInUrl,
26
+ githubUrl: params.githubUrl,
27
+ website: params.website,
28
+ alternateEmailAddresses: params.alternateEmailAddresses,
29
+ sourceId: params.sourceId,
30
+ creditedToUserId: params.creditedToUserId,
31
+ location: params.location,
32
+ }, {
33
+ auth: {
34
+ username: authToken,
35
+ password: "",
36
+ },
37
+ });
38
+ if (!response.data.success) {
39
+ throw new Error(response.data.errors.join("; "));
40
+ }
41
+ });
42
+ exports.default = createCandidate;
@@ -0,0 +1,3 @@
1
+ import { ashbyCreateNoteFunction } from "../../autogen/types";
2
+ declare const createNote: ashbyCreateNoteFunction;
3
+ export default createNote;
@@ -0,0 +1,32 @@
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 createNote = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ const { candidateId, note } = params;
15
+ const { authToken } = authParams;
16
+ if (!authToken) {
17
+ throw new Error("Auth token is required");
18
+ }
19
+ const response = yield axiosClient_1.axiosClient.post(`https://api.ashbyhq.com/candidate.createNote`, {
20
+ candidateId,
21
+ note,
22
+ }, {
23
+ auth: {
24
+ username: authToken,
25
+ password: "",
26
+ },
27
+ });
28
+ if (!response.data.success) {
29
+ throw new Error(response.data.errors.join("; "));
30
+ }
31
+ });
32
+ exports.default = createNote;
@@ -0,0 +1,3 @@
1
+ import { ashbyGetCandidateInfoFunction } from "../../autogen/types";
2
+ declare const getCandidateInfo: ashbyGetCandidateInfoFunction;
3
+ export default getCandidateInfo;
@@ -0,0 +1,34 @@
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 getCandidateInfo = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ const { candidateId } = params;
15
+ const { authToken } = authParams;
16
+ if (!authToken) {
17
+ throw new Error("Auth token is required");
18
+ }
19
+ const response = yield axiosClient_1.axiosClient.post(`https://api.ashbyhq.com/candidate.info`, {
20
+ id: candidateId,
21
+ }, {
22
+ auth: {
23
+ username: authToken,
24
+ password: "",
25
+ },
26
+ });
27
+ if (!response.data.success) {
28
+ throw new Error(response.data.errors.join("; "));
29
+ }
30
+ return {
31
+ candidate: response.data,
32
+ };
33
+ });
34
+ exports.default = getCandidateInfo;
@@ -0,0 +1,3 @@
1
+ import { ashbyListCandidateNotesFunction } from "../../autogen/types";
2
+ declare const listCandidateNotes: ashbyListCandidateNotesFunction;
3
+ export default listCandidateNotes;