@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.
- package/dist/actions/actionMapper.js +8 -1
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +79 -18
- package/dist/actions/autogen/types.d.ts +39 -0
- package/dist/actions/autogen/types.js +43 -8
- package/dist/actions/groups.js +4 -1
- package/dist/actions/invoke.js +11 -22
- package/dist/actions/parse.js +231 -244
- package/dist/actions/providers/asana/commentAsanaTask.js +8 -15
- package/dist/actions/providers/asana/createAsanaTask.js +20 -21
- package/dist/actions/providers/asana/getTasksDetails.js +18 -34
- package/dist/actions/providers/asana/listAsanaTasksByProject.js +62 -79
- package/dist/actions/providers/asana/searchAsanaTasks.js +6 -16
- package/dist/actions/providers/asana/updateAsanaTask.js +16 -15
- package/dist/actions/providers/asana/utils.js +47 -64
- package/dist/actions/providers/bing/getTopNSearchResultUrls.js +4 -14
- package/dist/actions/providers/confluence/fetchPageContent.js +5 -15
- package/dist/actions/providers/confluence/overwritePage.js +5 -14
- package/dist/actions/providers/finnhub/getBasicFinancials.js +7 -19
- package/dist/actions/providers/finnhub/symbolLookup.js +3 -12
- package/dist/actions/providers/firecrawl/deepResearch.js +11 -21
- package/dist/actions/providers/firecrawl/getTopNSearchResultUrls.js +8 -21
- package/dist/actions/providers/firecrawl/scrapeTweetDataWithNitter.js +4 -13
- package/dist/actions/providers/firecrawl/scrapeUrl.js +16 -21
- package/dist/actions/providers/firecrawl/searchAndScrape.js +6 -17
- package/dist/actions/providers/generic/fillTemplate.js +2 -11
- package/dist/actions/providers/github/createBranch.js +9 -18
- package/dist/actions/providers/github/createOrUpdateFile.js +6 -15
- package/dist/actions/providers/github/createPullRequest.js +5 -14
- package/dist/actions/providers/github/fetchFile.d.ts +3 -0
- package/dist/actions/providers/github/fetchFile.js +131 -0
- package/dist/actions/providers/github/getBranch.js +4 -13
- package/dist/actions/providers/github/getContents.d.ts +3 -0
- package/dist/actions/providers/github/getContents.js +41 -0
- package/dist/actions/providers/github/getFileContent.js +6 -16
- package/dist/actions/providers/github/getPullRequestDetails.js +39 -18
- package/dist/actions/providers/github/listCommits.js +17 -15
- package/dist/actions/providers/github/listDirectory.js +13 -25
- package/dist/actions/providers/github/listPullRequests.js +4 -13
- package/dist/actions/providers/github/searchOrganization.js +29 -49
- package/dist/actions/providers/github/utils.js +5 -16
- package/dist/actions/providers/gitlab/getFileContent.js +13 -24
- package/dist/actions/providers/gitlab/getMergeRequest.js +18 -30
- package/dist/actions/providers/gitlab/listDirectory.js +15 -27
- package/dist/actions/providers/gitlab/searchGroup.js +45 -52
- package/dist/actions/providers/gitlab/utils.js +19 -32
- package/dist/actions/providers/google-oauth/addGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/addTextToTopOfDoc.js +3 -12
- package/dist/actions/providers/google-oauth/appendRowsToSpreadsheet.js +4 -13
- package/dist/actions/providers/google-oauth/createNewGoogleDoc.js +7 -17
- package/dist/actions/providers/google-oauth/createPresentation.js +7 -13
- package/dist/actions/providers/google-oauth/createSpreadsheet.js +7 -13
- package/dist/actions/providers/google-oauth/deleteCalendarEvent.js +3 -12
- package/dist/actions/providers/google-oauth/deleteGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/deleteRowFromSpreadsheet.js +3 -12
- package/dist/actions/providers/google-oauth/editAGoogleCalendarEvent.js +4 -14
- package/dist/actions/providers/google-oauth/getDriveFileContentById.js +23 -33
- package/dist/actions/providers/google-oauth/getGroup.js +3 -12
- package/dist/actions/providers/google-oauth/getPresentation.js +23 -37
- package/dist/actions/providers/google-oauth/hasGroupMember.js +3 -12
- package/dist/actions/providers/google-oauth/listCalendarEvents.js +27 -21
- package/dist/actions/providers/google-oauth/listCalendars.js +4 -14
- package/dist/actions/providers/google-oauth/listGroupMembers.js +4 -13
- package/dist/actions/providers/google-oauth/listGroups.js +4 -14
- package/dist/actions/providers/google-oauth/queryGoogleBigQuery.js +10 -21
- package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +11 -14
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +3 -12
- package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +12 -23
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +30 -42
- package/dist/actions/providers/google-oauth/searchDriveByQueryAndGetFileContent.js +9 -20
- package/dist/actions/providers/google-oauth/updateCalendarEvent.js +3 -12
- package/dist/actions/providers/google-oauth/updateDoc.js +3 -12
- package/dist/actions/providers/google-oauth/updatePresentation.js +3 -12
- package/dist/actions/providers/google-oauth/updateRowsInSpreadsheet.js +4 -13
- package/dist/actions/providers/google-oauth/updateSpreadsheet.js +3 -12
- package/dist/actions/providers/google-oauth/utils/decodeMessage.js +7 -8
- package/dist/actions/providers/googleSearch/customSearch.js +18 -36
- package/dist/actions/providers/googlemail/listGmailThreads.js +7 -16
- package/dist/actions/providers/googlemail/replyToGmail.d.ts +3 -0
- package/dist/actions/providers/googlemail/replyToGmail.js +89 -0
- package/dist/actions/providers/googlemail/searchGmailMessages.js +10 -20
- package/dist/actions/providers/googlemail/sendGmail.js +7 -17
- package/dist/actions/providers/googlemaps/nearbysearchRestaurants.js +13 -25
- package/dist/actions/providers/googlemaps/validateAddress.js +3 -12
- package/dist/actions/providers/hubspot/getCompanies.js +4 -14
- package/dist/actions/providers/hubspot/getCompanyDetails.js +3 -12
- package/dist/actions/providers/hubspot/getContactDetails.js +3 -12
- package/dist/actions/providers/hubspot/getContacts.js +4 -14
- package/dist/actions/providers/hubspot/getDealDetails.js +3 -12
- package/dist/actions/providers/hubspot/getDeals.js +3 -12
- package/dist/actions/providers/hubspot/getTicketDetails.js +3 -12
- package/dist/actions/providers/hubspot/getTickets.js +3 -12
- package/dist/actions/providers/jira/assignJiraTicket.js +4 -13
- package/dist/actions/providers/jira/commentJiraTicket.js +3 -12
- package/dist/actions/providers/jira/createJiraTicket.js +22 -18
- package/dist/actions/providers/jira/createServiceDeskRequest.js +3 -12
- package/dist/actions/providers/jira/getJiraDCIssuesByQuery.js +5 -14
- package/dist/actions/providers/jira/getJiraIssuesByQuery.js +19 -29
- package/dist/actions/providers/jira/getJiraTicketDetails.js +3 -12
- package/dist/actions/providers/jira/getJiraTicketHistory.js +3 -12
- package/dist/actions/providers/jira/moveJiraTicketToProject.js +11 -21
- package/dist/actions/providers/jira/publicCommentOnServiceDeskRequest.js +3 -12
- package/dist/actions/providers/jira/updateJiraTicketDetails.js +15 -15
- package/dist/actions/providers/jira/updateJiraTicketStatus.js +4 -13
- package/dist/actions/providers/jira/utils.js +104 -126
- package/dist/actions/providers/linear/getIssueDetails.js +10 -20
- package/dist/actions/providers/linear/getIssues.js +11 -21
- package/dist/actions/providers/linear/getProjectDetails.js +10 -20
- package/dist/actions/providers/linear/getProjects.js +6 -16
- package/dist/actions/providers/linear/getTeamDetails.js +7 -17
- package/dist/actions/providers/linear/getTeams.js +5 -15
- package/dist/actions/providers/looker/enableUserByEmail.js +5 -14
- package/dist/actions/providers/math/add.js +2 -11
- package/dist/actions/providers/microsoft/createDocument.js +4 -13
- package/dist/actions/providers/microsoft/getDocument.js +4 -13
- package/dist/actions/providers/microsoft/messageTeamsChannel.js +4 -13
- package/dist/actions/providers/microsoft/messageTeamsChat.js +4 -13
- package/dist/actions/providers/microsoft/updateDocument.js +4 -13
- package/dist/actions/providers/microsoft/updateSpreadsheet.js +4 -13
- package/dist/actions/providers/microsoft/utils.js +9 -20
- package/dist/actions/providers/mongodb/insertMongoDoc.js +5 -14
- package/dist/actions/providers/notion/searchByTitle.js +3 -12
- package/dist/actions/providers/nws/getForecastForLocation.js +4 -13
- package/dist/actions/providers/oktaOrg/getOktaUserByName.js +3 -12
- package/dist/actions/providers/openstreetmap/getLatitudeLongitudeFromLocation.js +3 -12
- package/dist/actions/providers/perplexity/perplexityDeepResearch.js +11 -21
- package/dist/actions/providers/resend/sendEmail.js +3 -12
- package/dist/actions/providers/resend/sendEmailHtml.js +3 -12
- package/dist/actions/providers/salesforce/createCase.js +10 -13
- package/dist/actions/providers/salesforce/createRecord.js +3 -12
- package/dist/actions/providers/salesforce/executeReport.js +3 -12
- package/dist/actions/providers/salesforce/generateSalesReport.js +3 -12
- package/dist/actions/providers/salesforce/getRecord.js +3 -12
- package/dist/actions/providers/salesforce/getReportMetadata.js +11 -21
- package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +7 -17
- package/dist/actions/providers/salesforce/listReports.js +3 -12
- package/dist/actions/providers/salesforce/searchAllSalesforceRecords.js +3 -12
- package/dist/actions/providers/salesforce/searchSalesforceRecords.js +3 -12
- package/dist/actions/providers/salesforce/updateRecord.js +3 -12
- package/dist/actions/providers/slack/archiveChannel.js +9 -2
- package/dist/actions/providers/slack/createChannel.js +7 -17
- package/dist/actions/providers/slack/getChannelMembers.js +8 -18
- package/dist/actions/providers/slack/getChannelMessages.js +8 -18
- package/dist/actions/providers/slack/helpers.js +16 -47
- package/dist/actions/providers/slack/messageTransformers.js +10 -13
- package/dist/actions/providers/slack/sendDmFromBot.js +9 -19
- package/dist/actions/providers/slack/sendMessage.js +7 -17
- package/dist/actions/providers/slackUser/searchSlack.js +179 -212
- package/dist/actions/providers/slackUser/searchSlackRTS.js +20 -33
- package/dist/actions/providers/slackUser/utils.js +1 -1
- package/dist/actions/providers/snowflake/auth/getSnowflakeConnection.js +23 -34
- package/dist/actions/providers/snowflake/getRowByFieldValue.js +4 -13
- package/dist/actions/providers/snowflake/runSnowflakeQuery.js +9 -19
- package/dist/actions/providers/zendesk/addCommentToTicket.js +5 -14
- package/dist/actions/providers/zendesk/assignTicket.js +3 -12
- package/dist/actions/providers/zendesk/createZendeskTicket.js +3 -12
- package/dist/actions/providers/zendesk/getTicketDetails.js +3 -12
- package/dist/actions/providers/zendesk/listTickets.js +3 -12
- package/dist/actions/providers/zendesk/searchZendeskByQuery.js +3 -12
- package/dist/actions/providers/zendesk/updateTicketStatus.js +3 -12
- package/dist/actions/util/axiosClient.js +5 -5
- package/dist/app.js +14 -25
- package/dist/utils/google.js +122 -143
- package/dist/utils/pdf.js +10 -21
- package/package.json +10 -9
- package/dist/actions/providers/credal/callCopilot.d.ts +0 -3
- package/dist/actions/providers/credal/callCopilot.js +0 -36
- package/dist/actions/providers/math/index.d.ts +0 -1
- package/dist/actions/providers/math/index.js +0 -37
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +0 -43
- package/dist/actions/providers/slack/index.d.ts +0 -1
- package/dist/actions/providers/slack/index.js +0 -37
- package/dist/actions/providers/slack/listConversations.d.ts +0 -3
- package/dist/actions/providers/slack/listConversations.js +0 -41
|
@@ -1,16 +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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { getJiraApiConfig, getErrorMessage } from "./utils.js";
|
|
12
3
|
// https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-get
|
|
13
|
-
const getJiraTicketDetails =
|
|
4
|
+
const getJiraTicketDetails = async ({ params, authParams, }) => {
|
|
14
5
|
const { authToken, baseUrl } = authParams;
|
|
15
6
|
const { issueId } = params;
|
|
16
7
|
const { apiUrl } = getJiraApiConfig(authParams);
|
|
@@ -19,7 +10,7 @@ const getJiraTicketDetails = (_a) => __awaiter(void 0, [_a], void 0, function* (
|
|
|
19
10
|
}
|
|
20
11
|
const fullApiUrl = `${apiUrl}/issue/${issueId}`;
|
|
21
12
|
try {
|
|
22
|
-
const response =
|
|
13
|
+
const response = await axiosClient.get(fullApiUrl, {
|
|
23
14
|
headers: {
|
|
24
15
|
Authorization: `Bearer ${authToken}`,
|
|
25
16
|
Accept: "application/json",
|
|
@@ -43,5 +34,5 @@ const getJiraTicketDetails = (_a) => __awaiter(void 0, [_a], void 0, function* (
|
|
|
43
34
|
error: getErrorMessage(error),
|
|
44
35
|
};
|
|
45
36
|
}
|
|
46
|
-
}
|
|
37
|
+
};
|
|
47
38
|
export default getJiraTicketDetails;
|
|
@@ -1,15 +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 { getJiraApiConfig, getErrorMessage } from "./utils.js";
|
|
12
|
-
const getJiraTicketHistory =
|
|
3
|
+
const getJiraTicketHistory = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { issueId } = params;
|
|
15
6
|
const { apiUrl, strategy } = getJiraApiConfig(authParams);
|
|
@@ -18,7 +9,7 @@ const getJiraTicketHistory = (_a) => __awaiter(void 0, [_a], void 0, function* (
|
|
|
18
9
|
}
|
|
19
10
|
const fullApiUrl = `${apiUrl}${strategy.getHistoryEndpoint(issueId)}`;
|
|
20
11
|
try {
|
|
21
|
-
const response =
|
|
12
|
+
const response = await axiosClient.get(fullApiUrl, {
|
|
22
13
|
headers: {
|
|
23
14
|
Authorization: `Bearer ${authToken}`,
|
|
24
15
|
Accept: "application/json",
|
|
@@ -37,5 +28,5 @@ const getJiraTicketHistory = (_a) => __awaiter(void 0, [_a], void 0, function* (
|
|
|
37
28
|
error: getErrorMessage(error),
|
|
38
29
|
};
|
|
39
30
|
}
|
|
40
|
-
}
|
|
31
|
+
};
|
|
41
32
|
export default getJiraTicketHistory;
|
|
@@ -1,19 +1,9 @@
|
|
|
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 { getJiraApiConfig, getErrorMessage } from "./utils.js";
|
|
12
3
|
// Polling configuration
|
|
13
4
|
const POLL_INTERVAL_MS = 1000;
|
|
14
5
|
const MAX_POLL_ATTEMPTS = 30; // 30 seconds max wait
|
|
15
|
-
const moveJiraTicketToProject =
|
|
16
|
-
var _b;
|
|
6
|
+
const moveJiraTicketToProject = async ({ params, authParams, }) => {
|
|
17
7
|
const { authToken } = authParams;
|
|
18
8
|
const { issueId, targetProjectKey, targetIssueType } = params;
|
|
19
9
|
const { apiUrl, browseUrl } = getJiraApiConfig(authParams);
|
|
@@ -22,7 +12,7 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
22
12
|
}
|
|
23
13
|
try {
|
|
24
14
|
// First, get the current issue details
|
|
25
|
-
const issueResponse =
|
|
15
|
+
const issueResponse = await axiosClient.get(`${apiUrl}/issue/${issueId}`, {
|
|
26
16
|
headers: {
|
|
27
17
|
Authorization: `Bearer ${authToken}`,
|
|
28
18
|
Accept: "application/json",
|
|
@@ -41,7 +31,7 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
41
31
|
};
|
|
42
32
|
}
|
|
43
33
|
// Get the target project's available issue types
|
|
44
|
-
const issueTypesResponse =
|
|
34
|
+
const issueTypesResponse = await axiosClient.get(`${apiUrl}/issue/createmeta/${targetProjectKey}/issuetypes`, {
|
|
45
35
|
headers: {
|
|
46
36
|
Authorization: `Bearer ${authToken}`,
|
|
47
37
|
Accept: "application/json",
|
|
@@ -94,7 +84,7 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
94
84
|
};
|
|
95
85
|
let taskId;
|
|
96
86
|
try {
|
|
97
|
-
const response =
|
|
87
|
+
const response = await axiosClient.post(`${apiUrl}/bulk/issues/move`, movePayload, {
|
|
98
88
|
headers: {
|
|
99
89
|
Authorization: `Bearer ${authToken}`,
|
|
100
90
|
Accept: "application/json",
|
|
@@ -113,9 +103,9 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
113
103
|
// Poll the task until it completes
|
|
114
104
|
let taskStatus;
|
|
115
105
|
for (let attempt = 0; attempt < MAX_POLL_ATTEMPTS; attempt++) {
|
|
116
|
-
|
|
106
|
+
await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
117
107
|
try {
|
|
118
|
-
const taskResponse =
|
|
108
|
+
const taskResponse = await axiosClient.get(`${apiUrl}/task/${taskId}`, {
|
|
119
109
|
headers: {
|
|
120
110
|
Authorization: `Bearer ${authToken}`,
|
|
121
111
|
Accept: "application/json",
|
|
@@ -134,7 +124,7 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
134
124
|
};
|
|
135
125
|
}
|
|
136
126
|
}
|
|
137
|
-
catch
|
|
127
|
+
catch {
|
|
138
128
|
// Continue polling on transient errors
|
|
139
129
|
console.error("Error polling task status");
|
|
140
130
|
}
|
|
@@ -142,13 +132,13 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
142
132
|
if (!taskStatus || taskStatus.status !== "COMPLETE") {
|
|
143
133
|
return {
|
|
144
134
|
success: false,
|
|
145
|
-
error: `Move task did not complete within ${MAX_POLL_ATTEMPTS} seconds. Last status: ${
|
|
135
|
+
error: `Move task did not complete within ${MAX_POLL_ATTEMPTS} seconds. Last status: ${taskStatus?.status ?? "unknown"}`,
|
|
146
136
|
};
|
|
147
137
|
}
|
|
148
138
|
// Fetch the updated issue to get the new key (use immutable id since key changes on project move)
|
|
149
139
|
let newKey = currentIssueKey;
|
|
150
140
|
try {
|
|
151
|
-
const updatedIssueResponse =
|
|
141
|
+
const updatedIssueResponse = await axiosClient.get(`${apiUrl}/issue/${issueInternalId}`, {
|
|
152
142
|
headers: {
|
|
153
143
|
Authorization: `Bearer ${authToken}`,
|
|
154
144
|
Accept: "application/json",
|
|
@@ -156,7 +146,7 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
156
146
|
});
|
|
157
147
|
newKey = updatedIssueResponse.data.key;
|
|
158
148
|
}
|
|
159
|
-
catch
|
|
149
|
+
catch {
|
|
160
150
|
// Continue with original key
|
|
161
151
|
console.error("Error fetching updated issue");
|
|
162
152
|
}
|
|
@@ -172,5 +162,5 @@ const moveJiraTicketToProject = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
172
162
|
error: getErrorMessage(error),
|
|
173
163
|
};
|
|
174
164
|
}
|
|
175
|
-
}
|
|
165
|
+
};
|
|
176
166
|
export default moveJiraTicketToProject;
|
|
@@ -1,14 +1,5 @@
|
|
|
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
|
-
const publicCommentOnServiceDeskRequest =
|
|
2
|
+
const publicCommentOnServiceDeskRequest = async ({ params, authParams, }) => {
|
|
12
3
|
const { issueId, comment } = params;
|
|
13
4
|
const { authToken, cloudId } = authParams;
|
|
14
5
|
if (!cloudId || !authToken) {
|
|
@@ -16,7 +7,7 @@ const publicCommentOnServiceDeskRequest = (_a) => __awaiter(void 0, [_a], void 0
|
|
|
16
7
|
}
|
|
17
8
|
const baseUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/servicedeskapi/request/${issueId}/comment`;
|
|
18
9
|
try {
|
|
19
|
-
const response =
|
|
10
|
+
const response = await axiosClient.post(baseUrl, {
|
|
20
11
|
body: comment,
|
|
21
12
|
public: true,
|
|
22
13
|
}, {
|
|
@@ -39,5 +30,5 @@ const publicCommentOnServiceDeskRequest = (_a) => __awaiter(void 0, [_a], void 0
|
|
|
39
30
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
40
31
|
};
|
|
41
32
|
}
|
|
42
|
-
}
|
|
33
|
+
};
|
|
43
34
|
export default publicCommentOnServiceDeskRequest;
|
|
@@ -1,15 +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 { resolveRequestTypeField, getJiraApiConfig, getErrorMessage } from "./utils.js";
|
|
12
|
-
const updateJiraTicketDetails =
|
|
3
|
+
const updateJiraTicketDetails = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { issueId, summary, description, customFields, requestTypeId, projectKey } = params;
|
|
15
6
|
const { apiUrl, browseUrl, strategy } = getJiraApiConfig(authParams);
|
|
@@ -18,18 +9,27 @@ const updateJiraTicketDetails = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
18
9
|
}
|
|
19
10
|
const fullApiUrl = `${apiUrl}/issue/${issueId}`;
|
|
20
11
|
const formattedDescription = description ? strategy.formatText(description) : undefined;
|
|
21
|
-
const { field: requestTypeField, message: partialUpdateMessage } =
|
|
12
|
+
const { field: requestTypeField, message: partialUpdateMessage } = await resolveRequestTypeField(requestTypeId, projectKey, apiUrl, authToken);
|
|
22
13
|
const payload = {
|
|
23
|
-
fields:
|
|
14
|
+
fields: {
|
|
15
|
+
...(summary && { summary }),
|
|
16
|
+
...(formattedDescription && { description: formattedDescription }),
|
|
17
|
+
...(Object.keys(requestTypeField).length > 0 && requestTypeField),
|
|
18
|
+
...(customFields && customFields),
|
|
19
|
+
},
|
|
24
20
|
};
|
|
25
21
|
try {
|
|
26
|
-
|
|
22
|
+
await axiosClient.put(fullApiUrl, payload, {
|
|
27
23
|
headers: {
|
|
28
24
|
Authorization: `Bearer ${authToken}`,
|
|
29
25
|
Accept: "application/json",
|
|
30
26
|
},
|
|
31
27
|
});
|
|
32
|
-
return
|
|
28
|
+
return {
|
|
29
|
+
success: true,
|
|
30
|
+
ticketUrl: `${browseUrl}/browse/${issueId}`,
|
|
31
|
+
...(partialUpdateMessage && { error: partialUpdateMessage }),
|
|
32
|
+
};
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
35
35
|
console.error("Error updating Jira ticket:", error);
|
|
@@ -38,5 +38,5 @@ const updateJiraTicketDetails = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
38
38
|
error: getErrorMessage(error),
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
export default updateJiraTicketDetails;
|
|
@@ -1,15 +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 { getJiraApiConfig, getErrorMessage } from "./utils.js";
|
|
12
|
-
const updateJiraTicketStatus =
|
|
3
|
+
const updateJiraTicketStatus = async ({ params, authParams, }) => {
|
|
13
4
|
const { authToken } = authParams;
|
|
14
5
|
const { apiUrl, browseUrl } = getJiraApiConfig(authParams);
|
|
15
6
|
if (!authToken) {
|
|
@@ -19,7 +10,7 @@ const updateJiraTicketStatus = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
19
10
|
const transitionsUrl = `${apiUrl}/issue/${issueId}/transitions`;
|
|
20
11
|
try {
|
|
21
12
|
// API takes transition ID, so fetch available transitions the find ID of transition that matches given status name
|
|
22
|
-
const transitionsResponse =
|
|
13
|
+
const transitionsResponse = await axiosClient.get(transitionsUrl, {
|
|
23
14
|
headers: {
|
|
24
15
|
Authorization: `Bearer ${authToken}`,
|
|
25
16
|
Accept: "application/json",
|
|
@@ -34,7 +25,7 @@ const updateJiraTicketStatus = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
34
25
|
throw new Error(`Status '${status}' not found for this issue. Available statuses: ${transitions.map((t) => t.name).join(", ")}`);
|
|
35
26
|
}
|
|
36
27
|
// update status with transition ID
|
|
37
|
-
|
|
28
|
+
await axiosClient.post(transitionsUrl, { transition: { id: transition.id } }, {
|
|
38
29
|
headers: {
|
|
39
30
|
Authorization: `Bearer ${authToken}`,
|
|
40
31
|
Accept: "application/json",
|
|
@@ -53,5 +44,5 @@ const updateJiraTicketStatus = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
|
53
44
|
error: getErrorMessage(error),
|
|
54
45
|
};
|
|
55
46
|
}
|
|
56
|
-
}
|
|
47
|
+
};
|
|
57
48
|
export default updateJiraTicketStatus;
|
|
@@ -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 { axiosClient } from "../../util/axiosClient.js";
|
|
11
2
|
import { markdownToAdf } from "marklassian";
|
|
12
3
|
const cloudStrategy = {
|
|
@@ -14,7 +5,7 @@ const cloudStrategy = {
|
|
|
14
5
|
try {
|
|
15
6
|
return markdownToAdf(text);
|
|
16
7
|
}
|
|
17
|
-
catch
|
|
8
|
+
catch {
|
|
18
9
|
// Fallback to plain text ADF if markdown parsing fails
|
|
19
10
|
return {
|
|
20
11
|
type: "doc",
|
|
@@ -36,7 +27,7 @@ const cloudStrategy = {
|
|
|
36
27
|
getUserSearchParam: () => "query",
|
|
37
28
|
getSearchEndpoint: () => "/search/jql",
|
|
38
29
|
getHistoryEndpoint: (issueId) => `/issue/${issueId}/changelog`,
|
|
39
|
-
parseHistoryResponse: (response) =>
|
|
30
|
+
parseHistoryResponse: (response) => response?.data?.values,
|
|
40
31
|
};
|
|
41
32
|
const dataCenterStrategy = {
|
|
42
33
|
formatText: (text) => text,
|
|
@@ -53,7 +44,7 @@ const dataCenterStrategy = {
|
|
|
53
44
|
getUserSearchParam: () => "username",
|
|
54
45
|
getSearchEndpoint: () => "/search",
|
|
55
46
|
getHistoryEndpoint: (issueId) => `/issue/${issueId}?expand=changelog`,
|
|
56
|
-
parseHistoryResponse: (response) =>
|
|
47
|
+
parseHistoryResponse: (response) => response?.data?.changelog?.histories,
|
|
57
48
|
};
|
|
58
49
|
export function getPlatformStrategy(isDataCenter) {
|
|
59
50
|
return isDataCenter ? dataCenterStrategy : cloudStrategy;
|
|
@@ -90,137 +81,124 @@ export function getJiraApiConfig(authParams) {
|
|
|
90
81
|
export function isEmail(value) {
|
|
91
82
|
return typeof value === "string" && value.includes("@");
|
|
92
83
|
}
|
|
93
|
-
export function resolveAccountIdIfEmail(value, apiUrl, authToken, strategy) {
|
|
94
|
-
return
|
|
95
|
-
return isEmail(value) ? getUserAccountIdFromEmail(value, apiUrl, authToken, strategy) : null;
|
|
96
|
-
});
|
|
84
|
+
export async function resolveAccountIdIfEmail(value, apiUrl, authToken, strategy) {
|
|
85
|
+
return isEmail(value) ? getUserAccountIdFromEmail(value, apiUrl, authToken, strategy) : null;
|
|
97
86
|
}
|
|
98
|
-
export function getUserAccountIdFromEmail(email, apiUrl, authToken, strategy) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return userId;
|
|
115
|
-
}
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
const axiosError = error;
|
|
120
|
-
console.error("Error finding user:", axiosError.message);
|
|
121
|
-
return null;
|
|
87
|
+
export async function getUserAccountIdFromEmail(email, apiUrl, authToken, strategy) {
|
|
88
|
+
try {
|
|
89
|
+
const searchParam = strategy.getUserSearchParam();
|
|
90
|
+
const response = await axiosClient.get(`${apiUrl}/user/search?${searchParam}=${encodeURIComponent(email)}`, {
|
|
91
|
+
headers: {
|
|
92
|
+
Authorization: `Bearer ${authToken}`,
|
|
93
|
+
Accept: "application/json",
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
if (response.data && response.data.length > 0) {
|
|
97
|
+
const user = response.data[0];
|
|
98
|
+
// Use strategy to determine which field to use
|
|
99
|
+
const userId = strategy === dataCenterStrategy ? user.name || user.key : user.accountId;
|
|
100
|
+
if (!userId)
|
|
101
|
+
return null;
|
|
102
|
+
return userId;
|
|
122
103
|
}
|
|
123
|
-
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
const axiosError = error;
|
|
108
|
+
console.error("Error finding user:", axiosError.message);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
124
111
|
}
|
|
125
112
|
export function getErrorMessage(error) {
|
|
126
113
|
if (error instanceof Error)
|
|
127
114
|
return error.message;
|
|
128
115
|
return String(error);
|
|
129
116
|
}
|
|
130
|
-
export function resolveRequestTypeField(requestTypeId, projectKey, apiUrl, authToken) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
117
|
+
export async function resolveRequestTypeField(requestTypeId, projectKey, apiUrl, authToken) {
|
|
118
|
+
if (!requestTypeId || !projectKey) {
|
|
119
|
+
return { field: {} };
|
|
120
|
+
}
|
|
121
|
+
const result = await getRequestTypeCustomFieldId(projectKey, apiUrl, authToken);
|
|
122
|
+
const field = {};
|
|
123
|
+
if (result.fieldId) {
|
|
124
|
+
field[result.fieldId] = requestTypeId;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
field,
|
|
128
|
+
message: result.message,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export async function getRequestTypeCustomFieldId(projectKey, apiUrl, authToken) {
|
|
132
|
+
try {
|
|
133
|
+
const response = await axiosClient.get(`${apiUrl}/issue/createmeta?projectKeys=${projectKey}&expand=projects.issuetypes.fields`, {
|
|
134
|
+
headers: {
|
|
135
|
+
Authorization: `Bearer ${authToken}`,
|
|
136
|
+
Accept: "application/json",
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
const projects = response.data.projects;
|
|
140
|
+
if (!projects || projects.length === 0) {
|
|
141
|
+
return { fieldId: null };
|
|
134
142
|
}
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
|
|
143
|
+
const project = projects[0];
|
|
144
|
+
const issueTypes = project.issuetypes;
|
|
145
|
+
if (!issueTypes || issueTypes.length === 0) {
|
|
146
|
+
return { fieldId: null };
|
|
139
147
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
var _a;
|
|
149
|
-
try {
|
|
150
|
-
const response = yield axiosClient.get(`${apiUrl}/issue/createmeta?projectKeys=${projectKey}&expand=projects.issuetypes.fields`, {
|
|
151
|
-
headers: {
|
|
152
|
-
Authorization: `Bearer ${authToken}`,
|
|
153
|
-
Accept: "application/json",
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
const projects = response.data.projects;
|
|
157
|
-
if (!projects || projects.length === 0) {
|
|
158
|
-
return { fieldId: null };
|
|
159
|
-
}
|
|
160
|
-
const project = projects[0];
|
|
161
|
-
const issueTypes = project.issuetypes;
|
|
162
|
-
if (!issueTypes || issueTypes.length === 0) {
|
|
163
|
-
return { fieldId: null };
|
|
164
|
-
}
|
|
165
|
-
for (const issueType of issueTypes) {
|
|
166
|
-
const fields = issueType.fields;
|
|
167
|
-
if (fields) {
|
|
168
|
-
for (const [fieldId, fieldData] of Object.entries(fields)) {
|
|
169
|
-
if (fieldData && typeof fieldData === "object" && "name" in fieldData) {
|
|
170
|
-
const fieldInfo = fieldData;
|
|
171
|
-
if (fieldInfo.name === "Request Type") {
|
|
172
|
-
return { fieldId };
|
|
173
|
-
}
|
|
148
|
+
for (const issueType of issueTypes) {
|
|
149
|
+
const fields = issueType.fields;
|
|
150
|
+
if (fields) {
|
|
151
|
+
for (const [fieldId, fieldData] of Object.entries(fields)) {
|
|
152
|
+
if (fieldData && typeof fieldData === "object" && "name" in fieldData) {
|
|
153
|
+
const fieldInfo = fieldData;
|
|
154
|
+
if (fieldInfo.name === "Request Type") {
|
|
155
|
+
return { fieldId };
|
|
174
156
|
}
|
|
175
157
|
}
|
|
176
158
|
}
|
|
177
159
|
}
|
|
178
|
-
return { fieldId: null };
|
|
179
160
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
return { fieldId: null, message: `Error finding Request Type custom field: ${axiosError.message}` };
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
export function getUserEmailFromAccountId(accountId, client) {
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
if (!accountId)
|
|
194
|
-
return undefined;
|
|
195
|
-
try {
|
|
196
|
-
const userEmail = yield client.users.getUser({ accountId });
|
|
197
|
-
return userEmail.emailAddress;
|
|
161
|
+
return { fieldId: null };
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
const axiosError = error;
|
|
165
|
+
if (axiosError.response?.status === 404) {
|
|
166
|
+
return { fieldId: null, message: "Request Type field not found (optional for Service Desk), skipping..." };
|
|
198
167
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
console.error("Error fetching user email:", axiosError.message);
|
|
202
|
-
return undefined;
|
|
168
|
+
else {
|
|
169
|
+
return { fieldId: null, message: `Error finding Request Type custom field: ${axiosError.message}` };
|
|
203
170
|
}
|
|
204
|
-
}
|
|
171
|
+
}
|
|
205
172
|
}
|
|
206
|
-
export function
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
173
|
+
export async function getUserEmailFromAccountId(accountId, client) {
|
|
174
|
+
if (!accountId)
|
|
175
|
+
return undefined;
|
|
176
|
+
try {
|
|
177
|
+
const userEmail = await client.users.getUser({ accountId });
|
|
178
|
+
return userEmail.emailAddress;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
const axiosError = error;
|
|
182
|
+
console.error("Error fetching user email:", axiosError.message);
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export async function getUserInfoFromAccountId(accountId, client) {
|
|
187
|
+
if (!accountId)
|
|
188
|
+
return null;
|
|
189
|
+
try {
|
|
190
|
+
const user = await client.users.getUser({ accountId });
|
|
191
|
+
return {
|
|
192
|
+
id: user.accountId,
|
|
193
|
+
name: user?.displayName,
|
|
194
|
+
email: user?.emailAddress,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
const axiosError = error;
|
|
199
|
+
console.error("Error fetching user info:", axiosError.message);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
224
202
|
}
|
|
225
203
|
export function extractPlainText(adf) {
|
|
226
204
|
if (!adf || typeof adf !== "object")
|
|
@@ -231,7 +209,7 @@ export function extractPlainText(adf) {
|
|
|
231
209
|
return doc.content
|
|
232
210
|
.map((block) => {
|
|
233
211
|
if (block.type === "paragraph" && Array.isArray(block.content)) {
|
|
234
|
-
return block.content.map((inline) =>
|
|
212
|
+
return block.content.map((inline) => inline.text ?? "").join("");
|
|
235
213
|
}
|
|
236
214
|
return "";
|
|
237
215
|
})
|