@credal/actions 0.2.127 → 0.2.129

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 (39) hide show
  1. package/dist/actions/autogen/templates.js +909 -584
  2. package/dist/actions/autogen/types.d.ts +865 -938
  3. package/dist/actions/autogen/types.js +365 -212
  4. package/dist/actions/groups.d.ts +6 -0
  5. package/dist/actions/groups.js +261 -0
  6. package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
  7. package/dist/actions/providers/confluence/updatePage.js +47 -0
  8. package/dist/actions/providers/credal/callCopilot.d.ts +3 -0
  9. package/dist/actions/providers/credal/callCopilot.js +36 -0
  10. package/dist/actions/providers/firecrawl/scrapeUrl.js +11 -4
  11. package/dist/actions/providers/github/getFileContent.js +13 -5
  12. package/dist/actions/providers/github/listDirectory.js +12 -11
  13. package/dist/actions/providers/github/listPullRequests.js +58 -30
  14. package/dist/actions/providers/github/searchOrganization.d.ts +1 -1
  15. package/dist/actions/providers/github/searchOrganization.js +26 -4
  16. package/dist/actions/providers/gitlab/getFileContent.js +15 -6
  17. package/dist/actions/providers/gitlab/listDirectory.js +10 -6
  18. package/dist/actions/providers/gitlab/searchGroup.js +84 -55
  19. package/dist/actions/providers/google-oauth/getDriveFileContentById.js +10 -1
  20. package/dist/actions/providers/google-oauth/searchDriveByKeywordsAndGetFileContent.js +12 -4
  21. package/dist/actions/providers/google-oauth/searchDriveByQueryAndGetFileContent.js +2 -1
  22. package/dist/actions/providers/jamf/types.d.ts +8 -0
  23. package/dist/actions/providers/jamf/types.js +7 -0
  24. package/dist/actions/providers/jira/getJiraIssuesByQuery.js +9 -7
  25. package/dist/actions/providers/jira/getJiraTicketDetails.js +8 -1
  26. package/dist/actions/providers/math/index.d.ts +1 -0
  27. package/dist/actions/providers/math/index.js +37 -0
  28. package/dist/actions/providers/salesforce/getSalesforceRecordsByQuery.js +10 -3
  29. package/dist/actions/providers/salesforce/searchSalesforceRecords.js +9 -7
  30. package/dist/actions/providers/slack/archiveChannel.d.ts +3 -0
  31. package/dist/actions/providers/slack/archiveChannel.js +42 -0
  32. package/dist/actions/providers/slack/index.d.ts +1 -0
  33. package/dist/actions/providers/slack/index.js +37 -0
  34. package/dist/actions/providers/slack/listConversations.d.ts +3 -0
  35. package/dist/actions/providers/slack/listConversations.js +41 -0
  36. package/dist/actions/providers/slackUser/searchSlack.js +81 -8
  37. package/package.json +1 -1
  38. package/dist/actions/providers/jira/updateServiceDeskRequest.d.ts +0 -3
  39. package/dist/actions/providers/jira/updateServiceDeskRequest.js +0 -72
@@ -38,18 +38,22 @@ const listDirectory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ param
38
38
  `?path=${encodeURIComponent(path)}` +
39
39
  `&ref=${encodeURIComponent(ref)}`;
40
40
  const treeItems = yield gitlabFetch(url, authToken);
41
- const content = treeItems.map(item => {
41
+ const results = treeItems.map(item => {
42
42
  var _a;
43
43
  const isFile = item.type === "blob";
44
44
  const htmlUrl = `${gitlabBaseUrl}/${fullPath}/-/blob/${ref}/${item.path}`;
45
45
  return {
46
46
  name: item.name,
47
- path: item.path,
48
- type: item.type, // "blob" or "tree"
49
- size: isFile ? ((_a = item.size) !== null && _a !== void 0 ? _a : 0) : 0, // Size may not be returned; fallback to 0
50
- htmlUrl,
47
+ url: htmlUrl,
48
+ contents: {
49
+ name: item.name,
50
+ path: item.path,
51
+ type: item.type, // "blob" or "tree"
52
+ size: isFile ? ((_a = item.size) !== null && _a !== void 0 ? _a : 0) : 0, // Size may not be returned; fallback to 0
53
+ htmlUrl,
54
+ },
51
55
  };
52
56
  });
53
- return { content };
57
+ return { success: true, results };
54
58
  });
55
59
  export default listDirectory;
@@ -84,62 +84,91 @@ function getCommitDetails(input) {
84
84
  });
85
85
  }
86
86
  const searchGroup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
87
- const { authToken, baseUrl } = authParams;
88
- const gitlabBaseUrl = baseUrl !== null && baseUrl !== void 0 ? baseUrl : GITLAB_API_URL;
89
- const gitlabBaseApiUrl = `${gitlabBaseUrl}/api/v4`;
90
- if (!authToken)
91
- throw new Error(MISSING_AUTH_TOKEN);
92
- const { query, groupId, project } = params;
93
- const projectPathCache = createProjectPathCache();
94
- const fullProjectPath = project ? `${groupId}/${project}` : undefined;
95
- const encodedGroup = encodeURIComponent(groupId);
96
- const fetchSearchResults = (scope) => __awaiter(void 0, void 0, void 0, function* () {
97
- const endpoint = fullProjectPath
98
- ? `${gitlabBaseApiUrl}/projects/${encodeURIComponent(fullProjectPath)}/search?scope=${scope}&search=${encodeURIComponent(query)}`
99
- : `${gitlabBaseApiUrl}/groups/${encodedGroup}/search?scope=${scope}&search=${encodeURIComponent(query)}`;
100
- return gitlabFetch(endpoint, authToken);
101
- });
102
- const [mrResults, blobResults, commitResults] = yield Promise.all([
103
- fetchSearchResults("merge_requests"),
104
- fetchSearchResults("blobs"),
105
- fetchSearchResults("commits"),
106
- ]);
107
- const limitedMRResults = mrResults.slice(0, MAX_ISSUES_OR_PRS);
108
- const mergeRequests = yield Promise.all(limitedMRResults.map((metadata) => __awaiter(void 0, void 0, void 0, function* () {
109
- const endpoint = `${gitlabBaseApiUrl}/projects/${metadata.project_id}/merge_requests/${metadata.iid}/diffs`;
110
- let diffs = yield gitlabFetch(endpoint, authToken);
111
- diffs = (diffs || []).slice(0, MAX_FILES_PER_PR).map(diff => (Object.assign(Object.assign({}, diff), { diff: diff.diff ? diff.diff.split("\n").slice(0, MAX_PATCH_LINES).join("\n") : diff.diff })));
112
- return { metadata, diffs };
113
- })));
114
- const limitedBlobResults = blobResults.slice(0, MAX_CODE_RESULTS);
115
- const blobsWithUrls = yield Promise.all(limitedBlobResults.map(blob => enhanceBlobWithUrl(blob, authToken, gitlabBaseApiUrl, gitlabBaseUrl, projectPathCache)));
116
- const blobs = blobsWithUrls.map(blob => {
117
- const matches = mergeRequests
118
- .filter(mr => mr.metadata.project_id === blob.project_id && mr.diffs.some(diff => diff.new_path === blob.path))
119
- .map(mr => ({
120
- title: mr.metadata.title,
121
- web_url: mr.metadata.web_url,
122
- author: mr.metadata.author ? { name: mr.metadata.author.name } : undefined,
123
- merged_at: mr.metadata.merged_at,
124
- }));
87
+ try {
88
+ const { authToken, baseUrl } = authParams;
89
+ const gitlabBaseUrl = baseUrl !== null && baseUrl !== void 0 ? baseUrl : GITLAB_API_URL;
90
+ const gitlabBaseApiUrl = `${gitlabBaseUrl}/api/v4`;
91
+ if (!authToken)
92
+ throw new Error(MISSING_AUTH_TOKEN);
93
+ const { query, groupId, project } = params;
94
+ const projectPathCache = createProjectPathCache();
95
+ const fullProjectPath = project ? `${groupId}/${project}` : undefined;
96
+ const encodedGroup = encodeURIComponent(groupId);
97
+ const fetchSearchResults = (scope) => __awaiter(void 0, void 0, void 0, function* () {
98
+ const endpoint = fullProjectPath
99
+ ? `${gitlabBaseApiUrl}/projects/${encodeURIComponent(fullProjectPath)}/search?scope=${scope}&search=${encodeURIComponent(query)}`
100
+ : `${gitlabBaseApiUrl}/groups/${encodedGroup}/search?scope=${scope}&search=${encodeURIComponent(query)}`;
101
+ return gitlabFetch(endpoint, authToken);
102
+ });
103
+ const [mrResults, blobResults, commitResults] = yield Promise.all([
104
+ fetchSearchResults("merge_requests"),
105
+ fetchSearchResults("blobs"),
106
+ fetchSearchResults("commits"),
107
+ ]);
108
+ const limitedMRResults = mrResults.slice(0, MAX_ISSUES_OR_PRS);
109
+ const mergeRequests = yield Promise.all(limitedMRResults.map((metadata) => __awaiter(void 0, void 0, void 0, function* () {
110
+ const endpoint = `${gitlabBaseApiUrl}/projects/${metadata.project_id}/merge_requests/${metadata.iid}/diffs`;
111
+ let diffs = yield gitlabFetch(endpoint, authToken);
112
+ diffs = (diffs || []).slice(0, MAX_FILES_PER_PR).map(diff => (Object.assign(Object.assign({}, diff), { diff: diff.diff ? diff.diff.split("\n").slice(0, MAX_PATCH_LINES).join("\n") : diff.diff })));
113
+ return { metadata, diffs };
114
+ })));
115
+ const limitedBlobResults = blobResults.slice(0, MAX_CODE_RESULTS);
116
+ const blobsWithUrls = yield Promise.all(limitedBlobResults.map(blob => enhanceBlobWithUrl(blob, authToken, gitlabBaseApiUrl, gitlabBaseUrl, projectPathCache)));
117
+ const blobs = blobsWithUrls.map(blob => {
118
+ const matches = mergeRequests
119
+ .filter(mr => mr.metadata.project_id === blob.project_id && mr.diffs.some(diff => diff.new_path === blob.path))
120
+ .map(mr => ({
121
+ title: mr.metadata.title,
122
+ web_url: mr.metadata.web_url,
123
+ author: mr.metadata.author ? { name: mr.metadata.author.name } : undefined,
124
+ merged_at: mr.metadata.merged_at,
125
+ }));
126
+ return {
127
+ metadata: Object.assign(Object.assign({}, blob), { data: blob.data.split("\n").slice(0, MAX_FRAGMENT_LINES).join("\n") }),
128
+ matchedMergeRequests: matches,
129
+ };
130
+ });
131
+ const limitedCommitResults = commitResults.slice(0, MAX_COMMITS);
132
+ const commits = yield Promise.all(limitedCommitResults.map(commit => getCommitDetails({
133
+ projectId: commit.project_id,
134
+ sha: commit.id,
135
+ authToken,
136
+ baseUrl: gitlabBaseApiUrl,
137
+ webBaseUrl: gitlabBaseUrl,
138
+ projectPathCache,
139
+ })));
140
+ // Transform results into the new standardized format
141
+ const results = [
142
+ ...mergeRequests.map(mr => ({
143
+ name: mr.metadata.title,
144
+ url: mr.metadata.web_url,
145
+ type: "mergeRequest",
146
+ contents: mr,
147
+ })),
148
+ ...blobs.map(blob => ({
149
+ name: blob.metadata.filename,
150
+ url: blob.metadata.web_url,
151
+ type: "blob",
152
+ contents: blob,
153
+ })),
154
+ ...commits.map(commit => ({
155
+ name: commit.message.split("\n")[0], // Use first line of commit message as name
156
+ url: commit.web_url,
157
+ type: "commit",
158
+ contents: commit,
159
+ })),
160
+ ];
125
161
  return {
126
- metadata: Object.assign(Object.assign({}, blob), { data: blob.data.split("\n").slice(0, MAX_FRAGMENT_LINES).join("\n") }),
127
- matchedMergeRequests: matches,
162
+ success: true,
163
+ results,
128
164
  };
129
- });
130
- const limitedCommitResults = commitResults.slice(0, MAX_COMMITS);
131
- const commits = yield Promise.all(limitedCommitResults.map(commit => getCommitDetails({
132
- projectId: commit.project_id,
133
- sha: commit.id,
134
- authToken,
135
- baseUrl: gitlabBaseApiUrl,
136
- webBaseUrl: gitlabBaseUrl,
137
- projectPathCache,
138
- })));
139
- return {
140
- mergeRequests,
141
- blobs,
142
- commits,
143
- };
165
+ }
166
+ catch (error) {
167
+ return {
168
+ success: false,
169
+ error: error instanceof Error ? error.message : "An unknown error occurred",
170
+ results: [],
171
+ };
172
+ }
144
173
  });
145
174
  export default searchGroup;
@@ -115,7 +115,16 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
115
115
  // TODO in the future do this around the most valuable snippet of the doc?
116
116
  content = content.slice(0, charLimit);
117
117
  }
118
- return { success: true, content, fileName, fileLength: originalLength };
118
+ return {
119
+ success: true,
120
+ results: [
121
+ {
122
+ name: fileName,
123
+ url: `${BASE_URL}${encodeURIComponent(params.fileId)}`,
124
+ contents: { content, fileName, fileLength: originalLength },
125
+ },
126
+ ],
127
+ };
119
128
  }
120
129
  catch (error) {
121
130
  console.error("Error getting Google Drive file content", error);
@@ -13,7 +13,7 @@ import getDriveFileContentById from "./getDriveFileContentById.js";
13
13
  const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
14
  var _b;
15
15
  if (!authParams.authToken) {
16
- return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
16
+ return { success: false, error: MISSING_AUTH_TOKEN };
17
17
  }
18
18
  const { searchQuery, limit, searchDriveByDrive, orderByQuery, fileSizeLimit: maxChars } = params;
19
19
  const query = searchQuery
@@ -27,11 +27,12 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
27
27
  });
28
28
  // If search failed, return error
29
29
  if (!searchResult.success) {
30
- return { success: false, error: searchResult.error, files: [] };
30
+ return { success: false, error: searchResult.error };
31
31
  }
32
32
  // For each file, fetch its content in parallel
33
33
  const files = (_b = searchResult.files) !== null && _b !== void 0 ? _b : [];
34
34
  const contentPromises = files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
35
+ var _a, _b, _c;
35
36
  try {
36
37
  const contentResult = yield getDriveFileContentById({
37
38
  params: { fileId: file.id, limit: maxChars },
@@ -42,7 +43,7 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
42
43
  name: file.name,
43
44
  mimeType: file.mimeType,
44
45
  url: file.url,
45
- content: contentResult.success ? contentResult.content : undefined,
46
+ content: contentResult.success ? (_c = (_b = (_a = contentResult.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.contents) === null || _c === void 0 ? void 0 : _c.content : undefined,
46
47
  };
47
48
  }
48
49
  catch (error) {
@@ -57,6 +58,13 @@ const searchDriveByKeywordsAndGetFileContent = (_a) => __awaiter(void 0, [_a], v
57
58
  }));
58
59
  const filesWithContent = yield Promise.all(contentPromises);
59
60
  // Return combined results
60
- return { success: true, files: filesWithContent };
61
+ return {
62
+ success: true,
63
+ results: filesWithContent.map(file => ({
64
+ name: file.name,
65
+ url: file.url,
66
+ contents: file,
67
+ })),
68
+ };
61
69
  });
62
70
  export default searchDriveByKeywordsAndGetFileContent;
@@ -28,6 +28,7 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
28
28
  // For each file, fetch its content in parallel
29
29
  const files = (_b = searchResult.files) !== null && _b !== void 0 ? _b : [];
30
30
  const contentPromises = files.map((file) => __awaiter(void 0, void 0, void 0, function* () {
31
+ var _a, _b, _c;
31
32
  try {
32
33
  const contentResult = yield getDriveFileContentById({
33
34
  params: { fileId: file.id, limit: maxChars },
@@ -38,7 +39,7 @@ const searchDriveByQueryAndGetFileContent = (_a) => __awaiter(void 0, [_a], void
38
39
  name: file.name,
39
40
  mimeType: file.mimeType,
40
41
  url: file.url,
41
- content: contentResult.success ? contentResult.content : undefined,
42
+ content: contentResult.success ? (_c = (_b = (_a = contentResult.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.contents) === null || _c === void 0 ? void 0 : _c.content : undefined,
42
43
  };
43
44
  }
44
45
  catch (error) {
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ export declare const TokenResponseSchema: z.ZodObject<{
3
+ token: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ token: string;
6
+ }, {
7
+ token: string;
8
+ }>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokenResponseSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.TokenResponseSchema = zod_1.z.object({
6
+ token: zod_1.z.string(),
7
+ });
@@ -48,10 +48,12 @@ const getJiraIssuesByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* (
48
48
  });
49
49
  return {
50
50
  success: true,
51
- records: {
52
- issues: response.data.issues.map(issue => {
53
- var _a, _b, _c, _d;
54
- return ({
51
+ results: response.data.issues.map(issue => {
52
+ var _a, _b, _c, _d;
53
+ return ({
54
+ name: issue.key,
55
+ url: `${baseUrl}/browse/${issue.key}`,
56
+ contents: {
55
57
  id: issue.id,
56
58
  key: issue.key,
57
59
  summary: issue.fields.summary,
@@ -78,9 +80,9 @@ const getJiraIssuesByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* (
78
80
  resolution: ((_d = issue.fields.resolution) === null || _d === void 0 ? void 0 : _d.name) || null,
79
81
  dueDate: issue.fields.duedate || null,
80
82
  url: `${baseUrl}/browse/${issue.key}`,
81
- });
82
- }),
83
- },
83
+ },
84
+ });
85
+ }),
84
86
  };
85
87
  }
86
88
  catch (error) {
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { axiosClient } from "../../util/axiosClient.js";
11
+ // https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-rest-api-2-issue-issueidorkey-get
11
12
  const getJiraTicketDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
12
13
  const { authToken, cloudId } = authParams;
13
14
  const { issueId } = params;
@@ -24,7 +25,13 @@ const getJiraTicketDetails = (_a) => __awaiter(void 0, [_a], void 0, function* (
24
25
  });
25
26
  return {
26
27
  success: true,
27
- data: response.data,
28
+ results: [
29
+ {
30
+ name: response.data.key,
31
+ url: response.data.self,
32
+ contents: response.data,
33
+ },
34
+ ],
28
35
  };
29
36
  }
30
37
  catch (error) {
@@ -0,0 +1 @@
1
+ export * as add from "./add";
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.add = void 0;
37
+ exports.add = __importStar(require("./add"));
@@ -36,15 +36,22 @@ const getSalesforceRecordsByQuery = (_a) => __awaiter(void 0, [_a], void 0, func
36
36
  try {
37
37
  const response = yield axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
38
38
  // Salesforce record types are confusing and non standard
39
+ const recordsWithUrl =
39
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- const recordsWithUrl = (_c = response.data.records) === null || _c === void 0 ? void 0 : _c.map((record) => {
41
+ ((_c = response.data.records) === null || _c === void 0 ? void 0 : _c.map((record) => {
41
42
  const recordId = record.Id;
42
43
  const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
43
44
  return Object.assign(Object.assign({}, record), { webUrl });
44
- });
45
+ })) || [];
45
46
  return {
46
47
  success: true,
47
- records: Object.assign(Object.assign({}, response.data), { records: response.data.records ? recordsWithUrl : undefined }),
48
+ results:
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ recordsWithUrl.map((record) => ({
51
+ name: record.Name,
52
+ url: record.webUrl,
53
+ content: record,
54
+ })) || [],
48
55
  };
49
56
  }
50
57
  catch (error) {
@@ -41,13 +41,15 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
41
41
  }
42
42
  }
43
43
  // Salesforce record types are confusing and non standard
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- const recordsWithUrl = response.data.searchRecords.map((record) => {
46
- const recordId = record.Id;
47
- const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
48
- return Object.assign(Object.assign({}, record), { webUrl });
49
- });
50
- return { success: true, searchRecords: recordsWithUrl };
44
+ return {
45
+ success: true,
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ results: response.data.searchRecords.map((record) => {
48
+ const recordId = record.Id;
49
+ const webUrl = recordId ? `${baseUrl}/lightning/r/${recordId}/view` : undefined;
50
+ return { name: record.Name, url: webUrl, contents: record };
51
+ }),
52
+ };
51
53
  }
52
54
  catch (error) {
53
55
  console.error("Error retrieving Salesforce record:", error);
@@ -0,0 +1,3 @@
1
+ import type { slackArchiveChannelFunction } from "../../autogen/types.js";
2
+ declare const archiveChannel: slackArchiveChannelFunction;
3
+ export default archiveChannel;
@@ -0,0 +1,42 @@
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
+ import { WebClient } from "@slack/web-api";
11
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
+ import { getSlackChannels } from "./helpers.js";
13
+ const archiveChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ if (!authParams.authToken) {
15
+ throw new Error(MISSING_AUTH_TOKEN);
16
+ }
17
+ try {
18
+ const client = new WebClient(authParams.authToken);
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 });
27
+ if (!result.ok) {
28
+ return {
29
+ success: false,
30
+ error: result.error || "Unknown error archiving channel",
31
+ };
32
+ }
33
+ return { success: true };
34
+ }
35
+ catch (error) {
36
+ return {
37
+ success: false,
38
+ error: error instanceof Error ? error.message : "Unknown error archiving channel",
39
+ };
40
+ }
41
+ });
42
+ export default archiveChannel;
@@ -0,0 +1 @@
1
+ export * as listConversations from "./listConversations";
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.listConversations = void 0;
37
+ exports.listConversations = __importStar(require("./listConversations"));
@@ -0,0 +1,3 @@
1
+ import type { slackListConversationsFunction } from "../../autogen/types";
2
+ declare const slackListConversations: slackListConversationsFunction;
3
+ export default slackListConversations;
@@ -0,0 +1,41 @@
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 web_api_1 = require("@slack/web-api");
13
+ const helpers_1 = require("./helpers");
14
+ const slackListConversations = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
15
+ const client = new web_api_1.WebClient(authParams.authToken);
16
+ try {
17
+ const allChannels = yield (0, helpers_1.getSlackChannels)(client);
18
+ const filteredChannels = [];
19
+ for (const channel of allChannels) {
20
+ if (channel.name && channel.topic && channel.topic.value && channel.purpose && channel.purpose.value) {
21
+ const purpose = channel.purpose.value;
22
+ const topic = channel.topic.value;
23
+ const name = channel.name;
24
+ filteredChannels.push(Object.assign(Object.assign({}, channel), { purpose, topic, name }));
25
+ }
26
+ }
27
+ return {
28
+ channels: filteredChannels,
29
+ };
30
+ }
31
+ catch (error) {
32
+ if (error instanceof Error) {
33
+ // Enhance error with more context
34
+ throw new Error(`Failed to list Slack conversations: ${error.message}`);
35
+ }
36
+ else {
37
+ throw error;
38
+ }
39
+ }
40
+ });
41
+ exports.default = slackListConversations;