@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,21 +1,12 @@
|
|
|
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 { ApiError, axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const listReports =
|
|
2
|
+
const listReports = async ({ authParams, }) => {
|
|
12
3
|
const { authToken, baseUrl } = authParams;
|
|
13
4
|
if (!authToken || !baseUrl) {
|
|
14
5
|
return { success: false, error: "authToken and baseUrl are required for Salesforce API" };
|
|
15
6
|
}
|
|
16
7
|
const url = `${baseUrl}/services/data/v65.0/analytics/reports`;
|
|
17
8
|
try {
|
|
18
|
-
const response =
|
|
9
|
+
const response = await axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
|
|
19
10
|
return {
|
|
20
11
|
success: true,
|
|
21
12
|
reports: response.data,
|
|
@@ -32,5 +23,5 @@ const listReports = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authPar
|
|
|
32
23
|
: "An unknown error occurred",
|
|
33
24
|
};
|
|
34
25
|
}
|
|
35
|
-
}
|
|
26
|
+
};
|
|
36
27
|
export default listReports;
|
|
@@ -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 { ApiError, axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const searchAllSalesforceRecords =
|
|
2
|
+
const searchAllSalesforceRecords = async ({ params, authParams, }) => {
|
|
12
3
|
const { authToken, baseUrl } = authParams;
|
|
13
4
|
const { keyword, maxLimit } = params;
|
|
14
5
|
if (!authToken || !baseUrl) {
|
|
@@ -34,7 +25,7 @@ const searchAllSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, funct
|
|
|
34
25
|
Task(Id, Subject, Description, Status, WhatId, WhoId, ActivityDate, Account.Name),
|
|
35
26
|
Case(Id, Subject, Status, Priority, Origin, Account.Name, Contact.Name, Description, CreatedDate) ${customObject ? ", " + customObject : ""} LIMIT ${params.limit && params.limit <= maxLimitValue ? params.limit : maxLimitValue}`)}`;
|
|
36
27
|
try {
|
|
37
|
-
const response =
|
|
28
|
+
const response = await axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
|
|
38
29
|
for (const record of response.data.searchRecords) {
|
|
39
30
|
if (record.Article_Body__c) {
|
|
40
31
|
record.Article_Body__c = record.Article_Body__c
|
|
@@ -80,5 +71,5 @@ const searchAllSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, funct
|
|
|
80
71
|
: "An unknown error occurred",
|
|
81
72
|
};
|
|
82
73
|
}
|
|
83
|
-
}
|
|
74
|
+
};
|
|
84
75
|
export default searchAllSalesforceRecords;
|
|
@@ -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 { ApiError, axiosClient } from "../../util/axiosClient.js";
|
|
11
|
-
const searchSalesforceRecords =
|
|
2
|
+
const searchSalesforceRecords = async ({ params, authParams, }) => {
|
|
12
3
|
const { authToken, baseUrl } = authParams;
|
|
13
4
|
const { keyword, recordType, fieldsToSearch, maxLimit } = params;
|
|
14
5
|
const searchFields = Array.from(new Set([...fieldsToSearch, "Id"]));
|
|
@@ -23,7 +14,7 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
23
14
|
.replace(/-/g, "\\-"); // Escape dashes
|
|
24
15
|
const url = `${baseUrl}/services/data/v64.0/search/?q=${encodeURIComponent(`FIND {${escapedKeyword}} RETURNING ${recordType} (${searchFields.join(", ") + (dateFieldExists ? " ORDER BY CreatedDate DESC" : "")}) LIMIT ${params.limit && params.limit <= maxLimitValue ? params.limit : maxLimitValue}`)}`;
|
|
25
16
|
try {
|
|
26
|
-
const response =
|
|
17
|
+
const response = await axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
|
|
27
18
|
if (recordType === "Knowledge__kav") {
|
|
28
19
|
for (const record of response.data.searchRecords) {
|
|
29
20
|
if (record.Article_Body__c) {
|
|
@@ -71,5 +62,5 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
71
62
|
: "An unknown error occurred",
|
|
72
63
|
};
|
|
73
64
|
}
|
|
74
|
-
}
|
|
65
|
+
};
|
|
75
66
|
export default searchSalesforceRecords;
|
|
@@ -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 updateRecord =
|
|
2
|
+
const updateRecord = async ({ params, authParams, }) => {
|
|
12
3
|
const { authToken, baseUrl } = authParams;
|
|
13
4
|
const { recordType, recordId, fieldsToUpdate } = params;
|
|
14
5
|
if (!authToken || !baseUrl) {
|
|
@@ -19,7 +10,7 @@ const updateRecord = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
19
10
|
}
|
|
20
11
|
const url = `${baseUrl}/services/data/v56.0/sobjects/${recordType}/${recordId}`;
|
|
21
12
|
try {
|
|
22
|
-
|
|
13
|
+
await axiosClient.patch(url, fieldsToUpdate, {
|
|
23
14
|
headers: {
|
|
24
15
|
Authorization: `Bearer ${authToken}`,
|
|
25
16
|
"Content-Type": "application/json",
|
|
@@ -48,5 +39,5 @@ const updateRecord = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params
|
|
|
48
39
|
error: errorMessage,
|
|
49
40
|
};
|
|
50
41
|
}
|
|
51
|
-
}
|
|
42
|
+
};
|
|
52
43
|
export default updateRecord;
|
|
@@ -9,14 +9,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { WebClient } from "@slack/web-api";
|
|
11
11
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
+
import { getSlackChannels } from "./helpers.js";
|
|
12
13
|
const archiveChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
13
14
|
if (!authParams.authToken) {
|
|
14
15
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
15
16
|
}
|
|
16
17
|
try {
|
|
17
18
|
const client = new WebClient(authParams.authToken);
|
|
18
|
-
const {
|
|
19
|
-
const
|
|
19
|
+
const { channelName } = params;
|
|
20
|
+
const allChannels = yield getSlackChannels(client);
|
|
21
|
+
const channel = allChannels.find(channel => channel.name == channelName);
|
|
22
|
+
if (!channel || !channel.id) {
|
|
23
|
+
throw Error(`Channel with name ${channelName} not found`);
|
|
24
|
+
}
|
|
25
|
+
yield client.conversations.join({ channel: channel.id });
|
|
26
|
+
const result = yield client.conversations.archive({ channel: channel.id });
|
|
20
27
|
if (!result.ok) {
|
|
21
28
|
return {
|
|
22
29
|
success: false,
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { WebClient } from "@slack/web-api";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
|
-
const createChannel =
|
|
13
|
-
var _b;
|
|
3
|
+
const createChannel = async ({ params, authParams, }) => {
|
|
14
4
|
if (!authParams.authToken) {
|
|
15
5
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
16
6
|
}
|
|
@@ -18,12 +8,12 @@ const createChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
18
8
|
try {
|
|
19
9
|
const client = new WebClient(authParams.authToken);
|
|
20
10
|
const { channelName, isPrivate } = params;
|
|
21
|
-
const result =
|
|
11
|
+
const result = await client.conversations.create({
|
|
22
12
|
name: channelName,
|
|
23
13
|
is_private: !!isPrivate,
|
|
24
14
|
});
|
|
25
15
|
const { ok, channel, error } = result;
|
|
26
|
-
if (!ok || !
|
|
16
|
+
if (!ok || !channel?.id) {
|
|
27
17
|
return {
|
|
28
18
|
success: false,
|
|
29
19
|
error: error || "Unknown error creating channel",
|
|
@@ -35,15 +25,15 @@ const createChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
35
25
|
error: "userEmail must be provided in authParams to invite user to private channel",
|
|
36
26
|
};
|
|
37
27
|
}
|
|
38
|
-
const userID =
|
|
39
|
-
if (!
|
|
28
|
+
const userID = await client.users.lookupByEmail({ email: userEmail });
|
|
29
|
+
if (!userID.user?.id) {
|
|
40
30
|
return {
|
|
41
31
|
success: false,
|
|
42
32
|
error: `Could not find user with email ${userEmail}`,
|
|
43
33
|
};
|
|
44
34
|
}
|
|
45
35
|
// Add the user who asked to create the channel to the channel
|
|
46
|
-
|
|
36
|
+
await client.conversations.invite({
|
|
47
37
|
channel: channel.id,
|
|
48
38
|
users: userID.user.id,
|
|
49
39
|
});
|
|
@@ -59,5 +49,5 @@ const createChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
59
49
|
error: error instanceof Error ? error.message : "Unknown error creating channel",
|
|
60
50
|
};
|
|
61
51
|
}
|
|
62
|
-
}
|
|
52
|
+
};
|
|
63
53
|
export default createChannel;
|
|
@@ -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 { WebClient } from "@slack/web-api";
|
|
11
2
|
import { getSlackChannels } from "./helpers.js";
|
|
12
3
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
13
|
-
const getChannelMembers =
|
|
4
|
+
const getChannelMembers = async ({ params, authParams, }) => {
|
|
14
5
|
if (!authParams.authToken) {
|
|
15
6
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
16
7
|
}
|
|
@@ -21,14 +12,14 @@ const getChannelMembers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
21
12
|
}
|
|
22
13
|
let channelId = inputChannelId;
|
|
23
14
|
if (!channelId) {
|
|
24
|
-
const allChannels =
|
|
15
|
+
const allChannels = await getSlackChannels(client);
|
|
25
16
|
const channel = allChannels.find(channel => channel.name === channelName);
|
|
26
17
|
if (!channel || !channel.id) {
|
|
27
18
|
throw Error(`Channel with name ${channelName} not found`);
|
|
28
19
|
}
|
|
29
20
|
channelId = channel.id;
|
|
30
21
|
}
|
|
31
|
-
const response =
|
|
22
|
+
const response = await client.conversations.members({
|
|
32
23
|
channel: channelId,
|
|
33
24
|
});
|
|
34
25
|
if (!response.ok) {
|
|
@@ -36,16 +27,15 @@ const getChannelMembers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
36
27
|
}
|
|
37
28
|
const memberIds = response.members || [];
|
|
38
29
|
// Fetch user information for each member
|
|
39
|
-
const members =
|
|
40
|
-
var _a;
|
|
30
|
+
const members = await Promise.all(memberIds.map(async (userId) => {
|
|
41
31
|
try {
|
|
42
|
-
const userInfo =
|
|
32
|
+
const userInfo = await client.users.info({ user: userId });
|
|
43
33
|
if (userInfo.ok && userInfo.user) {
|
|
44
34
|
const user = userInfo.user;
|
|
45
35
|
return {
|
|
46
36
|
id: user.id || userId,
|
|
47
37
|
name: user.real_name || user.name || "",
|
|
48
|
-
email:
|
|
38
|
+
email: user.profile?.email || "",
|
|
49
39
|
};
|
|
50
40
|
}
|
|
51
41
|
}
|
|
@@ -58,10 +48,10 @@ const getChannelMembers = (_a) => __awaiter(void 0, [_a], void 0, function* ({ p
|
|
|
58
48
|
name: "",
|
|
59
49
|
email: "",
|
|
60
50
|
};
|
|
61
|
-
}))
|
|
51
|
+
}));
|
|
62
52
|
return {
|
|
63
53
|
success: true,
|
|
64
54
|
members,
|
|
65
55
|
};
|
|
66
|
-
}
|
|
56
|
+
};
|
|
67
57
|
export default getChannelMembers;
|
|
@@ -1,18 +1,8 @@
|
|
|
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 { WebClient } from "@slack/web-api";
|
|
11
2
|
import { getSlackChannels } from "./helpers.js";
|
|
12
3
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
13
4
|
import { extractMessageText, transformToSlackMessage, simplifyFile, removeRedundantFields, } from "./messageTransformers.js";
|
|
14
|
-
const getChannelMessages =
|
|
15
|
-
var _b;
|
|
5
|
+
const getChannelMessages = async ({ params, authParams, }) => {
|
|
16
6
|
if (!authParams.authToken) {
|
|
17
7
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
18
8
|
}
|
|
@@ -23,14 +13,14 @@ const getChannelMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
23
13
|
}
|
|
24
14
|
let channelId = inputChannelId;
|
|
25
15
|
if (!channelId) {
|
|
26
|
-
const allChannels =
|
|
16
|
+
const allChannels = await getSlackChannels(client);
|
|
27
17
|
const channel = allChannels.find(channel => channel.name === channelName);
|
|
28
18
|
if (!channel || !channel.id) {
|
|
29
19
|
throw Error(`Channel with name ${channelName} not found`);
|
|
30
20
|
}
|
|
31
21
|
channelId = channel.id;
|
|
32
22
|
}
|
|
33
|
-
const messages =
|
|
23
|
+
const messages = await client.conversations.history({
|
|
34
24
|
channel: channelId,
|
|
35
25
|
oldest: oldest,
|
|
36
26
|
latest: latest,
|
|
@@ -43,11 +33,11 @@ const getChannelMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
43
33
|
let processedMessages = messages.messages;
|
|
44
34
|
// Fetch thread replies if requested
|
|
45
35
|
if (includeThreadReplies) {
|
|
46
|
-
processedMessages =
|
|
36
|
+
processedMessages = await Promise.all(processedMessages.map(async (msg) => {
|
|
47
37
|
// If message has replies, fetch them
|
|
48
38
|
if (msg.reply_count && msg.reply_count > 0 && msg.ts) {
|
|
49
39
|
try {
|
|
50
|
-
const threadReplies =
|
|
40
|
+
const threadReplies = await client.conversations.replies({
|
|
51
41
|
channel: channelId,
|
|
52
42
|
ts: msg.ts,
|
|
53
43
|
limit: 20,
|
|
@@ -85,7 +75,7 @@ const getChannelMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
85
75
|
}
|
|
86
76
|
}
|
|
87
77
|
return msg;
|
|
88
|
-
}))
|
|
78
|
+
}));
|
|
89
79
|
}
|
|
90
80
|
// Transform and enrich messages with extracted text
|
|
91
81
|
processedMessages = processedMessages.map(msg => {
|
|
@@ -132,7 +122,7 @@ const getChannelMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
132
122
|
return {
|
|
133
123
|
messages: processedMessages,
|
|
134
124
|
hasMore: messages.has_more,
|
|
135
|
-
nextCursor:
|
|
125
|
+
nextCursor: messages.response_metadata?.next_cursor,
|
|
136
126
|
};
|
|
137
|
-
}
|
|
127
|
+
};
|
|
138
128
|
export default getChannelMessages;
|
|
@@ -1,51 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export async function getSlackChannels(client) {
|
|
2
|
+
const limit = 100;
|
|
3
|
+
const allChannels = [];
|
|
4
|
+
const allChannelsIterable = await client.paginate("conversations.list", {
|
|
5
|
+
exclude_archived: true,
|
|
6
|
+
limit,
|
|
7
|
+
types: "public_channel,private_channel",
|
|
8
8
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
export function getSlackChannels(client) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
var _a, e_1, _b, _c;
|
|
20
|
-
const limit = 100;
|
|
21
|
-
const allChannels = [];
|
|
22
|
-
const allChannelsIterable = yield client.paginate("conversations.list", {
|
|
23
|
-
exclude_archived: true,
|
|
24
|
-
limit,
|
|
25
|
-
types: "public_channel,private_channel",
|
|
26
|
-
});
|
|
27
|
-
try {
|
|
28
|
-
for (var _d = true, _e = __asyncValues(allChannelsIterable), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
29
|
-
_c = _f.value;
|
|
30
|
-
_d = false;
|
|
31
|
-
const page = _c;
|
|
32
|
-
if (!page.channels)
|
|
33
|
-
continue; // Not expected
|
|
34
|
-
for (const channel of page.channels) {
|
|
35
|
-
const channelId = channel.id;
|
|
36
|
-
if (channelId) {
|
|
37
|
-
allChannels.push(Object.assign(Object.assign({}, channel), { id: channelId }));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
9
|
+
for await (const page of allChannelsIterable) {
|
|
10
|
+
if (!page.channels)
|
|
11
|
+
continue; // Not expected
|
|
12
|
+
for (const channel of page.channels) {
|
|
13
|
+
const channelId = channel.id;
|
|
14
|
+
if (channelId) {
|
|
15
|
+
allChannels.push({ ...channel, id: channelId });
|
|
40
16
|
}
|
|
41
17
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
46
|
-
}
|
|
47
|
-
finally { if (e_1) throw e_1.error; }
|
|
48
|
-
}
|
|
49
|
-
return allChannels;
|
|
50
|
-
});
|
|
18
|
+
}
|
|
19
|
+
return allChannels;
|
|
51
20
|
}
|
|
@@ -96,13 +96,11 @@ export function removeRedundantFields(obj) {
|
|
|
96
96
|
* Extracts all visible text from a Slack message
|
|
97
97
|
*/
|
|
98
98
|
export function extractMessageText(m) {
|
|
99
|
-
var _a, _b, _c, _d;
|
|
100
99
|
if (!m)
|
|
101
100
|
return undefined;
|
|
102
101
|
const pieces = [];
|
|
103
102
|
// ---- Rich text helpers ----
|
|
104
103
|
const walkRichTextInline = (el) => {
|
|
105
|
-
var _a;
|
|
106
104
|
const blockPieces = [];
|
|
107
105
|
switch (el.type) {
|
|
108
106
|
case "text":
|
|
@@ -124,7 +122,7 @@ export function extractMessageText(m) {
|
|
|
124
122
|
blockPieces.push(`@${el.range}`);
|
|
125
123
|
break;
|
|
126
124
|
case "date":
|
|
127
|
-
blockPieces.push(
|
|
125
|
+
blockPieces.push(el.fallback ?? `<date:${el.timestamp}>`);
|
|
128
126
|
break;
|
|
129
127
|
case "team":
|
|
130
128
|
blockPieces.push(`<team:${el.team_id}>`);
|
|
@@ -156,11 +154,10 @@ export function extractMessageText(m) {
|
|
|
156
154
|
};
|
|
157
155
|
// ---- Block helpers ----
|
|
158
156
|
const walkBlock = (block) => {
|
|
159
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
160
157
|
const blockPieces = [];
|
|
161
158
|
switch (block.type) {
|
|
162
159
|
case "section":
|
|
163
|
-
if (
|
|
160
|
+
if (block.text?.text)
|
|
164
161
|
blockPieces.push(block.text.text);
|
|
165
162
|
if (block.fields) {
|
|
166
163
|
for (const f of block.fields)
|
|
@@ -180,7 +177,7 @@ export function extractMessageText(m) {
|
|
|
180
177
|
}
|
|
181
178
|
break;
|
|
182
179
|
case "header":
|
|
183
|
-
if (
|
|
180
|
+
if (block.text?.text)
|
|
184
181
|
blockPieces.push(block.text.text);
|
|
185
182
|
break;
|
|
186
183
|
case "rich_text":
|
|
@@ -191,19 +188,19 @@ export function extractMessageText(m) {
|
|
|
191
188
|
blockPieces.push(block.text);
|
|
192
189
|
break;
|
|
193
190
|
case "video":
|
|
194
|
-
if (
|
|
191
|
+
if (block.title?.text)
|
|
195
192
|
blockPieces.push(block.title.text);
|
|
196
|
-
if (
|
|
193
|
+
if (block.description?.text)
|
|
197
194
|
blockPieces.push(block.description.text);
|
|
198
195
|
break;
|
|
199
196
|
case "image":
|
|
200
|
-
if (
|
|
197
|
+
if (block.title?.text)
|
|
201
198
|
blockPieces.push(block.title.text);
|
|
202
199
|
break;
|
|
203
200
|
case "input":
|
|
204
|
-
if (
|
|
201
|
+
if (block.label?.text)
|
|
205
202
|
blockPieces.push(block.label.text);
|
|
206
|
-
if (
|
|
203
|
+
if (block.hint?.text)
|
|
207
204
|
blockPieces.push(block.hint.text);
|
|
208
205
|
break;
|
|
209
206
|
// divider, file, actions, input don't contribute visible text
|
|
@@ -236,8 +233,8 @@ export function extractMessageText(m) {
|
|
|
236
233
|
pieces.push(att.text);
|
|
237
234
|
if (att.fields) {
|
|
238
235
|
for (const f of att.fields) {
|
|
239
|
-
const title =
|
|
240
|
-
const value =
|
|
236
|
+
const title = f.title?.trim() ?? "";
|
|
237
|
+
const value = f.value?.trim() ?? "";
|
|
241
238
|
if (title || value) {
|
|
242
239
|
pieces.push(title && value ? `${title}: ${value}` : title || value);
|
|
243
240
|
}
|
|
@@ -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 { WebClient } from "@slack/web-api";
|
|
11
2
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
12
3
|
/**
|
|
@@ -17,16 +8,15 @@ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
|
17
8
|
* 2. Opens a DM channel with conversations.open (or uses existing)
|
|
18
9
|
* 3. Posts the message using chat.postMessage
|
|
19
10
|
*/
|
|
20
|
-
const sendDmFromBot =
|
|
21
|
-
var _b, _c;
|
|
11
|
+
const sendDmFromBot = async ({ params, authParams, }) => {
|
|
22
12
|
if (!authParams.authToken)
|
|
23
13
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
24
14
|
const client = new WebClient(authParams.authToken);
|
|
25
15
|
const { email, message } = params;
|
|
26
16
|
try {
|
|
27
17
|
// Step 1: Look up user by email
|
|
28
|
-
const userLookup =
|
|
29
|
-
const userId =
|
|
18
|
+
const userLookup = await client.users.lookupByEmail({ email });
|
|
19
|
+
const userId = userLookup.user?.id;
|
|
30
20
|
if (!userId) {
|
|
31
21
|
return {
|
|
32
22
|
success: false,
|
|
@@ -34,10 +24,10 @@ const sendDmFromBot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
34
24
|
};
|
|
35
25
|
}
|
|
36
26
|
// Step 2: Open DM conversation (or get existing one)
|
|
37
|
-
const conversationOpen =
|
|
27
|
+
const conversationOpen = await client.conversations.open({
|
|
38
28
|
users: userId,
|
|
39
29
|
});
|
|
40
|
-
const channelId =
|
|
30
|
+
const channelId = conversationOpen.channel?.id;
|
|
41
31
|
if (!channelId) {
|
|
42
32
|
return {
|
|
43
33
|
success: false,
|
|
@@ -45,7 +35,7 @@ const sendDmFromBot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
45
35
|
};
|
|
46
36
|
}
|
|
47
37
|
// Step 3: Send the message
|
|
48
|
-
const result =
|
|
38
|
+
const result = await client.chat.postMessage({
|
|
49
39
|
channel: channelId,
|
|
50
40
|
text: message,
|
|
51
41
|
});
|
|
@@ -59,13 +49,13 @@ const sendDmFromBot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
59
49
|
let permalink;
|
|
60
50
|
if (result.ts) {
|
|
61
51
|
try {
|
|
62
|
-
const permalinkResult =
|
|
52
|
+
const permalinkResult = await client.chat.getPermalink({
|
|
63
53
|
channel: channelId,
|
|
64
54
|
message_ts: result.ts,
|
|
65
55
|
});
|
|
66
56
|
permalink = permalinkResult.permalink;
|
|
67
57
|
}
|
|
68
|
-
catch
|
|
58
|
+
catch {
|
|
69
59
|
// Permalink fetch failed, but message was sent successfully
|
|
70
60
|
}
|
|
71
61
|
}
|
|
@@ -82,5 +72,5 @@ const sendDmFromBot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
|
|
|
82
72
|
error: error instanceof Error ? error.message : "Unknown error occurred",
|
|
83
73
|
};
|
|
84
74
|
}
|
|
85
|
-
}
|
|
75
|
+
};
|
|
86
76
|
export default sendDmFromBot;
|
|
@@ -1,18 +1,8 @@
|
|
|
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 { WebClient } from "@slack/web-api";
|
|
11
2
|
import { slackSendMessageOutputSchema, } from "../../autogen/types.js";
|
|
12
3
|
import { getSlackChannels } from "./helpers.js";
|
|
13
4
|
import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
|
14
|
-
const sendMessage =
|
|
15
|
-
var _b;
|
|
5
|
+
const sendMessage = async ({ params, authParams, }) => {
|
|
16
6
|
if (!authParams.authToken) {
|
|
17
7
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
18
8
|
}
|
|
@@ -23,15 +13,15 @@ const sendMessage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
23
13
|
const client = new WebClient(authParams.authToken);
|
|
24
14
|
let channelId = inputChannelId;
|
|
25
15
|
if (!channelId) {
|
|
26
|
-
const allChannels =
|
|
27
|
-
channelId =
|
|
16
|
+
const allChannels = await getSlackChannels(client);
|
|
17
|
+
channelId = allChannels.find(channel => channel.name == channelName)?.id;
|
|
28
18
|
}
|
|
29
19
|
if (!channelId) {
|
|
30
20
|
throw Error(`Channel with name ${channelName} not found`);
|
|
31
21
|
}
|
|
32
22
|
try {
|
|
33
23
|
// First try sending as Markdown blocks (mrkdwn)
|
|
34
|
-
|
|
24
|
+
await client.chat.postMessage({
|
|
35
25
|
channel: channelId,
|
|
36
26
|
text: message, // Fallback text for notifications/clients that don't render blocks
|
|
37
27
|
blocks: [
|
|
@@ -48,10 +38,10 @@ const sendMessage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
48
38
|
success: true,
|
|
49
39
|
});
|
|
50
40
|
}
|
|
51
|
-
catch
|
|
41
|
+
catch {
|
|
52
42
|
// On any error, retry once with plain text only (no blocks)
|
|
53
43
|
try {
|
|
54
|
-
|
|
44
|
+
await client.chat.postMessage({
|
|
55
45
|
channel: channelId,
|
|
56
46
|
text: message,
|
|
57
47
|
});
|
|
@@ -64,5 +54,5 @@ const sendMessage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
|
|
|
64
54
|
});
|
|
65
55
|
}
|
|
66
56
|
}
|
|
67
|
-
}
|
|
57
|
+
};
|
|
68
58
|
export default sendMessage;
|