@credal/actions 0.2.128 → 0.2.130

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.
@@ -771,7 +771,7 @@ export const slackUserSearchSlackDefinition = {
771
771
  },
772
772
  output: {
773
773
  type: "object",
774
- required: ["query", "results"],
774
+ required: ["query", "results", "currentUser"],
775
775
  properties: {
776
776
  query: {
777
777
  type: "string",
@@ -851,6 +851,25 @@ export const slackUserSearchSlackDefinition = {
851
851
  },
852
852
  },
853
853
  },
854
+ currentUser: {
855
+ type: "object",
856
+ required: ["userId"],
857
+ description: "The current user who's running the search",
858
+ properties: {
859
+ userId: {
860
+ type: "string",
861
+ description: "The ID of the current user",
862
+ },
863
+ userName: {
864
+ type: "string",
865
+ description: "The name of the current user",
866
+ },
867
+ userEmail: {
868
+ type: "string",
869
+ description: "The email of the current user",
870
+ },
871
+ },
872
+ },
854
873
  },
855
874
  },
856
875
  name: "searchSlack",
@@ -973,6 +973,19 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
973
973
  }[] | undefined;
974
974
  };
975
975
  }>, "many">;
976
+ currentUser: z.ZodObject<{
977
+ userId: z.ZodString;
978
+ userName: z.ZodOptional<z.ZodString>;
979
+ userEmail: z.ZodOptional<z.ZodString>;
980
+ }, "strip", z.ZodTypeAny, {
981
+ userId: string;
982
+ userEmail?: string | undefined;
983
+ userName?: string | undefined;
984
+ }, {
985
+ userId: string;
986
+ userEmail?: string | undefined;
987
+ userName?: string | undefined;
988
+ }>;
976
989
  }, "strip", z.ZodTypeAny, {
977
990
  query: string;
978
991
  results: {
@@ -993,6 +1006,11 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
993
1006
  }[] | undefined;
994
1007
  };
995
1008
  }[];
1009
+ currentUser: {
1010
+ userId: string;
1011
+ userEmail?: string | undefined;
1012
+ userName?: string | undefined;
1013
+ };
996
1014
  }, {
997
1015
  query: string;
998
1016
  results: {
@@ -1013,6 +1031,11 @@ export declare const slackUserSearchSlackOutputSchema: z.ZodObject<{
1013
1031
  }[] | undefined;
1014
1032
  };
1015
1033
  }[];
1034
+ currentUser: {
1035
+ userId: string;
1036
+ userEmail?: string | undefined;
1037
+ userName?: string | undefined;
1038
+ };
1016
1039
  }>;
1017
1040
  export type slackUserSearchSlackOutputType = z.infer<typeof slackUserSearchSlackOutputSchema>;
1018
1041
  export type slackUserSearchSlackFunction = ActionFunction<slackUserSearchSlackParamsType, AuthParamsType, slackUserSearchSlackOutputType>;
@@ -6267,12 +6290,12 @@ export declare const oktaResetPasswordParamsSchema: z.ZodObject<{
6267
6290
  sendEmail: z.ZodBoolean;
6268
6291
  revokeSessions: z.ZodOptional<z.ZodBoolean>;
6269
6292
  }, "strip", z.ZodTypeAny, {
6270
- sendEmail: boolean;
6271
6293
  userId: string;
6294
+ sendEmail: boolean;
6272
6295
  revokeSessions?: boolean | undefined;
6273
6296
  }, {
6274
- sendEmail: boolean;
6275
6297
  userId: string;
6298
+ sendEmail: boolean;
6276
6299
  revokeSessions?: boolean | undefined;
6277
6300
  }>;
6278
6301
  export type oktaResetPasswordParamsType = z.infer<typeof oktaResetPasswordParamsSchema>;
@@ -323,6 +323,13 @@ export const slackUserSearchSlackOutputSchema = z.object({
323
323
  }),
324
324
  }))
325
325
  .describe("Hydrated search results (threads or small context windows), sorted by ts desc."),
326
+ currentUser: z
327
+ .object({
328
+ userId: z.string().describe("The ID of the current user"),
329
+ userName: z.string().describe("The name of the current user").optional(),
330
+ userEmail: z.string().describe("The email of the current user").optional(),
331
+ })
332
+ .describe("The current user who's running the search"),
326
333
  });
327
334
  export const mathAddParamsSchema = z.object({
328
335
  a: z.number().describe("The first number to add"),
@@ -0,0 +1,6 @@
1
+ import type { ActionTemplate } from "./parse.js";
2
+ export type ActionGroups = Record<string, {
3
+ description: string;
4
+ actions: ActionTemplate[];
5
+ }>;
6
+ export declare const ACTION_GROUPS: ActionGroups;
@@ -0,0 +1,261 @@
1
+ import { genericFillTemplateDefinition, confluenceOverwritePageDefinition, googlemapsValidateAddressDefinition, mathAddDefinition, mongoInsertMongoDocDefinition, slackSendMessageDefinition, slackGetChannelMessagesDefinition, slackCreateChannelDefinition, slackArchiveChannelDefinition, snowflakeGetRowByFieldValueDefinition, zendeskCreateZendeskTicketDefinition, zendeskListZendeskTicketsDefinition, zendeskGetTicketDetailsDefinition, zendeskUpdateTicketStatusDefinition, zendeskAddCommentToTicketDefinition, zendeskAssignTicketDefinition, openstreetmapGetLatitudeLongitudeFromLocationDefinition, nwsGetForecastForLocationDefinition, jiraAssignJiraTicketDefinition, jiraCommentJiraTicketDefinition, jiraCreateJiraTicketDefinition, jiraGetJiraTicketDetailsDefinition, jiraGetJiraTicketHistoryDefinition, jiraUpdateJiraTicketDetailsDefinition, jiraUpdateJiraTicketStatusDefinition, jiraGetServiceDesksDefinition, jiraCreateServiceDeskRequestDefinition, googlemapsNearbysearchRestaurantsDefinition, firecrawlScrapeUrlDefinition, resendSendEmailDefinition, linkedinCreateShareLinkedinPostUrlDefinition, googleOauthCreateNewGoogleDocDefinition, xCreateShareXPostUrlDefinition, firecrawlScrapeTweetDataWithNitterDefinition, finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition, confluenceFetchPageContentDefinition, snowflakeRunSnowflakeQueryDefinition, lookerEnableUserByEmailDefinition, googleOauthUpdateDocDefinition, googleOauthScheduleCalendarMeetingDefinition, googleOauthListCalendarsDefinition, googleOauthListCalendarEventsDefinition, googleOauthUpdateCalendarEventDefinition, googleOauthDeleteCalendarEventDefinition, googleOauthCreateSpreadsheetDefinition, googleOauthUpdateSpreadsheetDefinition, googleOauthCreatePresentationDefinition, googleOauthUpdatePresentationDefinition, googleOauthSearchDriveByKeywordsDefinition, googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition, googleOauthListGroupsDefinition, googleOauthGetGroupDefinition, googleOauthListGroupMembersDefinition, googleOauthHasGroupMemberDefinition, googleOauthAddGroupMemberDefinition, googleOauthDeleteGroupMemberDefinition, salesforceUpdateRecordDefinition, salesforceCreateCaseDefinition, salesforceGenerateSalesReportDefinition, salesforceGetRecordDefinition, salesforceGetSalesforceRecordsByQueryDefinition, microsoftMessageTeamsChatDefinition, microsoftMessageTeamsChannelDefinition, asanaCommentTaskDefinition, asanaCreateTaskDefinition, asanaUpdateTaskDefinition, asanaSearchTasksDefinition, githubCreateOrUpdateFileDefinition, githubCreateBranchDefinition, githubCreatePullRequestDefinition, microsoftUpdateSpreadsheetDefinition, microsoftUpdateDocumentDefinition, microsoftCreateDocumentDefinition, microsoftGetDocumentDefinition, salesforceFetchSalesforceSchemaByObjectDefinition, firecrawlDeepResearchDefinition, jiraGetJiraIssuesByQueryDefinition, githubListPullRequestsDefinition, salesforceCreateRecordDefinition, ashbyCreateNoteDefinition, ashbyGetCandidateInfoDefinition, ashbyListCandidatesDefinition, ashbyListCandidateNotesDefinition, ashbySearchCandidatesDefinition, ashbyCreateCandidateDefinition, ashbyUpdateCandidateDefinition, ashbyAddCandidateToProjectDefinition, bingGetTopNSearchResultUrlsDefinition, gongGetGongTranscriptsDefinition, kandjiGetFVRecoveryKeyForDeviceDefinition, asanaListAsanaTasksByProjectDefinition, notionSearchByTitleDefinition, asanaGetTasksDetailsDefinition, linearGetIssueDetailsDefinition, linearGetProjectsDefinition, linearGetProjectDetailsDefinition, linearGetTeamDetailsDefinition, linearGetTeamsDefinition, jamfGetJamfComputerInventoryDefinition, jamfGetJamfFileVaultRecoveryKeyDefinition, oktaListOktaUsersDefinition, oktaGetOktaUserDefinition, oktaListOktaUserGroupsDefinition, oktaListOktaGroupsDefinition, oktaGetOktaGroupDefinition, oktaListOktaGroupMembersDefinition, oktaRemoveUserFromGroupDefinition, oktaAddUserToGroupDefinition, oktaResetPasswordDefinition, oktaResetMFADefinition, oktaListMFADefinition, jamfGetJamfUserComputerIdDefinition, jamfLockJamfComputerByIdDefinition, oktaTriggerOktaWorkflowDefinition, jiraOrgAssignJiraTicketDefinition, jiraOrgCreateJiraTicketDefinition, jiraOrgCommentJiraTicketDefinition, jiraOrgGetJiraTicketDetailsDefinition, jiraOrgGetJiraTicketHistoryDefinition, jiraOrgUpdateJiraTicketDetailsDefinition, jiraOrgUpdateJiraTicketStatusDefinition, jiraOrgGetJiraIssuesByQueryDefinition, googleOauthGetDriveFileContentByIdDefinition, googleOauthSearchDriveByQueryDefinition, googleOauthSearchDriveByQueryAndGetFileContentDefinition, githubGetFileContentDefinition, githubListDirectoryDefinition, } from "./autogen/templates.js";
2
+ export const ACTION_GROUPS = {
3
+ GENERIC: {
4
+ description: "Generic utility actions",
5
+ actions: [genericFillTemplateDefinition],
6
+ },
7
+ ASANA: {
8
+ description: "Actions for interacting with Asana",
9
+ actions: [
10
+ asanaCommentTaskDefinition,
11
+ asanaCreateTaskDefinition,
12
+ asanaUpdateTaskDefinition,
13
+ asanaSearchTasksDefinition,
14
+ asanaListAsanaTasksByProjectDefinition,
15
+ asanaGetTasksDetailsDefinition,
16
+ ],
17
+ },
18
+ SLACK_LIST_CONVERSATIONS: {
19
+ description: "Actions for interacting with Slack",
20
+ actions: [
21
+ slackSendMessageDefinition,
22
+ slackGetChannelMessagesDefinition,
23
+ slackCreateChannelDefinition,
24
+ slackArchiveChannelDefinition,
25
+ ],
26
+ },
27
+ CONFLUENCE: {
28
+ description: "Action for interacting with Confluence",
29
+ actions: [confluenceOverwritePageDefinition, confluenceFetchPageContentDefinition],
30
+ },
31
+ MATH_ADD: {
32
+ description: "Action for adding two numbers",
33
+ actions: [mathAddDefinition],
34
+ },
35
+ GOOGLE_MAPS: {
36
+ description: "Action for interacting with Google Maps",
37
+ actions: [googlemapsValidateAddressDefinition, googlemapsNearbysearchRestaurantsDefinition],
38
+ },
39
+ GOOGLE_DRIVE: {
40
+ description: "Action for interacting with Google Drive",
41
+ actions: [
42
+ googleOauthCreateNewGoogleDocDefinition,
43
+ googleOauthUpdateDocDefinition,
44
+ googleOauthCreateSpreadsheetDefinition,
45
+ googleOauthUpdateSpreadsheetDefinition,
46
+ googleOauthCreatePresentationDefinition,
47
+ googleOauthUpdatePresentationDefinition,
48
+ googleOauthSearchDriveByKeywordsDefinition,
49
+ googleOauthSearchDriveByQueryDefinition,
50
+ googleOauthSearchDriveByQueryAndGetFileContentDefinition,
51
+ googleOauthGetDriveFileContentByIdDefinition,
52
+ ],
53
+ },
54
+ GOOGLE_CALENDAR: {
55
+ description: "Actions for interacting with Google Calendar",
56
+ actions: [
57
+ googleOauthScheduleCalendarMeetingDefinition,
58
+ googleOauthListCalendarsDefinition,
59
+ googleOauthListCalendarEventsDefinition,
60
+ googleOauthUpdateCalendarEventDefinition,
61
+ googleOauthDeleteCalendarEventDefinition,
62
+ ],
63
+ },
64
+ GMAIL: {
65
+ description: "Actions for interacting with Gmail",
66
+ actions: [googlemailSearchGmailMessagesDefinition, googlemailListGmailThreadsDefinition],
67
+ },
68
+ LINKEDIN_SHARE_POST: {
69
+ description: "Action for creating a share post url on linkedin",
70
+ actions: [linkedinCreateShareLinkedinPostUrlDefinition],
71
+ },
72
+ ZENDESK_ACTIONS: {
73
+ description: "Actions for interacting with Zendesk",
74
+ actions: [
75
+ zendeskCreateZendeskTicketDefinition,
76
+ zendeskListZendeskTicketsDefinition,
77
+ zendeskGetTicketDetailsDefinition,
78
+ zendeskUpdateTicketStatusDefinition,
79
+ zendeskAddCommentToTicketDefinition,
80
+ zendeskAssignTicketDefinition,
81
+ ],
82
+ },
83
+ BING_SEARCH: {
84
+ description: "Action for searching Bing",
85
+ actions: [bingGetTopNSearchResultUrlsDefinition],
86
+ },
87
+ MONGO_INSERT_DOC: {
88
+ description: "Action for inserting a document into a MongoDB collection",
89
+ actions: [mongoInsertMongoDocDefinition],
90
+ },
91
+ SNOWFLAKE_ACTIONS: {
92
+ description: "Action for getting content from a Snowflake table",
93
+ actions: [snowflakeGetRowByFieldValueDefinition, snowflakeRunSnowflakeQueryDefinition],
94
+ },
95
+ JIRA_ACTIONS: {
96
+ description: "Action for interacting with Jira tickets",
97
+ actions: [
98
+ jiraAssignJiraTicketDefinition,
99
+ jiraCreateJiraTicketDefinition,
100
+ jiraCommentJiraTicketDefinition,
101
+ jiraGetJiraTicketDetailsDefinition,
102
+ jiraGetJiraTicketHistoryDefinition,
103
+ jiraUpdateJiraTicketDetailsDefinition,
104
+ jiraUpdateJiraTicketStatusDefinition,
105
+ jiraGetJiraIssuesByQueryDefinition,
106
+ jiraGetServiceDesksDefinition,
107
+ jiraCreateServiceDeskRequestDefinition,
108
+ ],
109
+ },
110
+ JIRA_ORG_ACTIONS: {
111
+ description: "Action for interacting with Jira tickets",
112
+ actions: [
113
+ jiraOrgAssignJiraTicketDefinition,
114
+ jiraOrgCreateJiraTicketDefinition,
115
+ jiraOrgCommentJiraTicketDefinition,
116
+ jiraOrgGetJiraTicketDetailsDefinition,
117
+ jiraOrgGetJiraTicketHistoryDefinition,
118
+ jiraOrgUpdateJiraTicketDetailsDefinition,
119
+ jiraOrgUpdateJiraTicketStatusDefinition,
120
+ jiraOrgGetJiraIssuesByQueryDefinition,
121
+ ],
122
+ },
123
+ OPENSTREETMAP_GET_LATITUDE_LONGITUDE_FROM_LOCATION: {
124
+ description: "Action for getting the latitude and longitude of a location",
125
+ actions: [openstreetmapGetLatitudeLongitudeFromLocationDefinition],
126
+ },
127
+ NWS_GET_FORECAST_FOR_LOCATION: {
128
+ description: "Action for getting the weather forecast for a location",
129
+ actions: [nwsGetForecastForLocationDefinition],
130
+ },
131
+ FIRECRAWL: {
132
+ description: "Actions for interacting with Firecrawl",
133
+ actions: [
134
+ firecrawlScrapeUrlDefinition,
135
+ firecrawlScrapeTweetDataWithNitterDefinition,
136
+ firecrawlDeepResearchDefinition,
137
+ ],
138
+ },
139
+ RESEND: {
140
+ description: "Action for sending an email",
141
+ actions: [resendSendEmailDefinition],
142
+ },
143
+ X: {
144
+ description: "Actions for interacting with X(formerly twitter)",
145
+ actions: [xCreateShareXPostUrlDefinition],
146
+ },
147
+ GONG: {
148
+ description: "Actions for interacting with Gong",
149
+ actions: [gongGetGongTranscriptsDefinition],
150
+ },
151
+ FINNHUB: {
152
+ description: "Action for interacting with Finnhub for stock market data",
153
+ actions: [finnhubSymbolLookupDefinition, finnhubGetBasicFinancialsDefinition],
154
+ },
155
+ JAMF: {
156
+ description: "Actions for interacting with Jamf",
157
+ actions: [
158
+ jamfGetJamfComputerInventoryDefinition,
159
+ jamfGetJamfFileVaultRecoveryKeyDefinition,
160
+ jamfGetJamfUserComputerIdDefinition,
161
+ jamfLockJamfComputerByIdDefinition,
162
+ ],
163
+ },
164
+ LOOKER: {
165
+ description: "Actions for interacting with Looker",
166
+ actions: [lookerEnableUserByEmailDefinition],
167
+ },
168
+ SALESFORCE: {
169
+ description: "Actions for interacting with Salesforce",
170
+ actions: [
171
+ salesforceUpdateRecordDefinition,
172
+ salesforceCreateRecordDefinition,
173
+ salesforceCreateCaseDefinition,
174
+ salesforceGenerateSalesReportDefinition,
175
+ salesforceGetRecordDefinition,
176
+ salesforceGetSalesforceRecordsByQueryDefinition,
177
+ salesforceFetchSalesforceSchemaByObjectDefinition,
178
+ ],
179
+ },
180
+ MICROSOFT: {
181
+ description: "Actions for interacting with Microsoft 365",
182
+ actions: [
183
+ microsoftMessageTeamsChatDefinition,
184
+ microsoftMessageTeamsChannelDefinition,
185
+ microsoftUpdateSpreadsheetDefinition,
186
+ microsoftUpdateDocumentDefinition,
187
+ microsoftCreateDocumentDefinition,
188
+ microsoftGetDocumentDefinition,
189
+ ],
190
+ },
191
+ KANDJI: {
192
+ description: "Actions for interacting with Kandji",
193
+ actions: [kandjiGetFVRecoveryKeyForDeviceDefinition],
194
+ },
195
+ GITHUB: {
196
+ description: "Actions for interacting with GitHub",
197
+ actions: [
198
+ githubCreateOrUpdateFileDefinition,
199
+ githubCreateBranchDefinition,
200
+ githubCreatePullRequestDefinition,
201
+ githubListPullRequestsDefinition,
202
+ githubGetFileContentDefinition,
203
+ githubListDirectoryDefinition,
204
+ ],
205
+ },
206
+ ASHBY: {
207
+ description: "Actions for interacting with Ashby",
208
+ actions: [
209
+ ashbyCreateNoteDefinition,
210
+ ashbyGetCandidateInfoDefinition,
211
+ ashbyListCandidatesDefinition,
212
+ ashbyListCandidateNotesDefinition,
213
+ ashbySearchCandidatesDefinition,
214
+ ashbyCreateCandidateDefinition,
215
+ ashbyUpdateCandidateDefinition,
216
+ ashbyAddCandidateToProjectDefinition,
217
+ ],
218
+ },
219
+ NOTION: {
220
+ description: "Actions for interacting with Notion",
221
+ actions: [notionSearchByTitleDefinition],
222
+ },
223
+ GOOGLE_GROUPS: {
224
+ description: "Google Workspace Groups management actions",
225
+ actions: [
226
+ googleOauthListGroupsDefinition,
227
+ googleOauthGetGroupDefinition,
228
+ googleOauthListGroupMembersDefinition,
229
+ googleOauthHasGroupMemberDefinition,
230
+ googleOauthAddGroupMemberDefinition,
231
+ googleOauthDeleteGroupMemberDefinition,
232
+ ],
233
+ },
234
+ OKTA: {
235
+ description: "Actions for interacting with Okta",
236
+ actions: [
237
+ oktaListOktaUsersDefinition,
238
+ oktaGetOktaUserDefinition,
239
+ oktaListOktaUserGroupsDefinition,
240
+ oktaListOktaGroupsDefinition,
241
+ oktaGetOktaGroupDefinition,
242
+ oktaListOktaGroupMembersDefinition,
243
+ oktaRemoveUserFromGroupDefinition,
244
+ oktaAddUserToGroupDefinition,
245
+ oktaResetPasswordDefinition,
246
+ oktaResetMFADefinition,
247
+ oktaListMFADefinition,
248
+ oktaTriggerOktaWorkflowDefinition,
249
+ ],
250
+ },
251
+ LINEAR: {
252
+ description: "Actions for interacting with Linear",
253
+ actions: [
254
+ linearGetIssueDetailsDefinition,
255
+ linearGetProjectsDefinition,
256
+ linearGetProjectDetailsDefinition,
257
+ linearGetTeamDetailsDefinition,
258
+ linearGetTeamsDefinition,
259
+ ],
260
+ },
261
+ };
@@ -0,0 +1,3 @@
1
+ import { confluenceUpdatePageFunction } from "../../../actions/autogen/types";
2
+ declare const confluenceUpdatePage: confluenceUpdatePageFunction;
3
+ export default confluenceUpdatePage;
@@ -0,0 +1,47 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
16
+ function getConfluenceApi(baseUrl, username, apiToken) {
17
+ const api = axios_1.default.create({
18
+ baseURL: baseUrl,
19
+ headers: {
20
+ Accept: "application/json",
21
+ // Tokens are associated with a specific user.
22
+ Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
23
+ },
24
+ });
25
+ return api;
26
+ }
27
+ const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
28
+ const { pageId, username, content, title } = params;
29
+ const { baseUrl, authToken } = authParams;
30
+ const api = getConfluenceApi(baseUrl, username, authToken);
31
+ // Get current version number
32
+ const response = yield api.get(`/api/v2/pages/${pageId}`);
33
+ const currVersion = response.data.version.number;
34
+ yield api.put(`/api/v2/pages/${pageId}`, {
35
+ id: pageId,
36
+ status: "current",
37
+ title,
38
+ body: {
39
+ representation: "storage",
40
+ value: content,
41
+ },
42
+ version: {
43
+ number: currVersion + 1,
44
+ },
45
+ });
46
+ });
47
+ exports.default = confluenceUpdatePage;
@@ -0,0 +1,3 @@
1
+ import type { credalCallCopilotFunction } from "../../autogen/types";
2
+ declare const callCopilot: credalCallCopilotFunction;
3
+ export default callCopilot;
@@ -0,0 +1,36 @@
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 sdk_1 = require("@credal/sdk");
13
+ const callCopilot = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ var _b;
15
+ const requestBody = {
16
+ agentId: params.agentId,
17
+ query: params.query,
18
+ userEmail: params.userEmail,
19
+ };
20
+ const baseUrl = (_b = authParams.baseUrl) !== null && _b !== void 0 ? _b : "https://app.credal.ai/api";
21
+ const client = new sdk_1.CredalClient({ environment: baseUrl, apiKey: authParams.apiKey });
22
+ const response = yield client.copilots.sendMessage({
23
+ agentId: requestBody.agentId,
24
+ message: requestBody.query,
25
+ userEmail: requestBody.userEmail,
26
+ });
27
+ return {
28
+ response: response.sendChatResult.type === "ai_response_result"
29
+ ? response.sendChatResult.response.message
30
+ : "Error getting response",
31
+ referencedSources: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.referencedSources : [],
32
+ sourcesInDataContext: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.sourcesInDataContext : [],
33
+ webSearchResults: response.sendChatResult.type === "ai_response_result" ? response.sendChatResult.webSearchResults : [],
34
+ };
35
+ });
36
+ exports.default = callCopilot;
@@ -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
+ });
@@ -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"));
@@ -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;
@@ -12,6 +12,10 @@ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
12
  import pLimit from "p-limit";
13
13
  const HIT_ENRICH_POOL = 5;
14
14
  const limitHit = pLimit(HIT_ENRICH_POOL);
15
+ const MENTION_USER_RE = /<@([UW][A-Z0-9]+)(?:\|[^>]+)?>/g;
16
+ const MENTION_CHANNEL_RE = /<#(C[A-Z0-9]+)(?:\|[^>]+)?>/g;
17
+ const SPECIAL_RE = /<!(channel|here|everyone)>/g;
18
+ const SUBTEAM_RE = /<!subteam\^([A-Z0-9]+)(?:\|[^>]+)?>/g; // user group
15
19
  class SlackUserCache {
16
20
  constructor(client) {
17
21
  this.client = client;
@@ -20,16 +24,16 @@ class SlackUserCache {
20
24
  }
21
25
  get(id) {
22
26
  return __awaiter(this, void 0, void 0, function* () {
23
- var _a, _b, _c, _d, _e, _f, _g, _h;
27
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
24
28
  const result = this.cache.get(id);
25
29
  if (result)
26
30
  return result;
27
31
  const res = yield this.client.users.info({ user: id });
28
32
  const u = {
29
- name: (_e = (_c = (_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.display_name) !== null && _c !== void 0 ? _c : (_d = res.user) === null || _d === void 0 ? void 0 : _d.real_name) !== null && _e !== void 0 ? _e : "",
30
- email: (_h = (_g = (_f = res.user) === null || _f === void 0 ? void 0 : _f.profile) === null || _g === void 0 ? void 0 : _g.email) !== null && _h !== void 0 ? _h : "",
33
+ name: (_g = (_e = (_c = (_b = (_a = res.user) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.display_name) !== null && _c !== void 0 ? _c : (_d = res.user) === null || _d === void 0 ? void 0 : _d.real_name) !== null && _e !== void 0 ? _e : (_f = res.user) === null || _f === void 0 ? void 0 : _f.name) !== null && _g !== void 0 ? _g : "",
34
+ email: (_k = (_j = (_h = res.user) === null || _h === void 0 ? void 0 : _h.profile) === null || _j === void 0 ? void 0 : _j.email) !== null && _k !== void 0 ? _k : "",
31
35
  };
32
- if (res.user && id && res.user.name) {
36
+ if (res.user && id) {
33
37
  this.cache.set(id, u);
34
38
  return u;
35
39
  }
@@ -70,14 +74,18 @@ function lookupUserIdsByEmail(client, emails, slackUserCache) {
70
74
  return __awaiter(this, void 0, void 0, function* () {
71
75
  const ids = [];
72
76
  const tasks = emails.map((raw) => __awaiter(this, void 0, void 0, function* () {
73
- var _a;
77
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
74
78
  const email = raw.trim();
75
79
  if (!email)
76
80
  return null;
77
81
  const res = yield client.users.lookupByEmail({ email });
78
82
  const id = (_a = res.user) === null || _a === void 0 ? void 0 : _a.id;
79
- if (res.user && id && res.user.name) {
80
- slackUserCache.set(id, { email, name: res.user.name });
83
+ const u = {
84
+ name: (_h = (_f = (_d = (_c = (_b = res.user) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.display_name) !== null && _d !== void 0 ? _d : (_e = res.user) === null || _e === void 0 ? void 0 : _e.real_name) !== null && _f !== void 0 ? _f : (_g = res.user) === null || _g === void 0 ? void 0 : _g.name) !== null && _h !== void 0 ? _h : "",
85
+ email: (_l = (_k = (_j = res.user) === null || _j === void 0 ? void 0 : _j.profile) === null || _k === void 0 ? void 0 : _k.email) !== null && _l !== void 0 ? _l : "",
86
+ };
87
+ if (res.user && id) {
88
+ slackUserCache.set(id, u);
81
89
  }
82
90
  if (id)
83
91
  return id;
@@ -171,11 +179,17 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
171
179
  const slackUserCache = new SlackUserCache(client);
172
180
  const { emails, channel, topic, timeRange, limit } = params;
173
181
  const parts = [];
182
+ const { user_id: myUserId } = yield client.auth.test();
183
+ if (!myUserId)
184
+ throw new Error("Failed to get my user ID.");
185
+ const me = yield slackUserCache.get(myUserId);
186
+ const currentUser = {
187
+ userId: myUserId,
188
+ userName: me === null || me === void 0 ? void 0 : me.name,
189
+ userEmail: me === null || me === void 0 ? void 0 : me.email,
190
+ };
174
191
  if (emails === null || emails === void 0 ? void 0 : emails.length) {
175
192
  const userIds = yield lookupUserIdsByEmail(client, emails, slackUserCache);
176
- const { user_id: myUserId } = yield client.auth.test();
177
- if (!myUserId)
178
- throw new Error("Failed to get my user ID.");
179
193
  const userIdsWithoutMe = userIds.filter(id => id !== myUserId);
180
194
  if (userIdsWithoutMe.length === 0)
181
195
  throw new Error("No users resolved from emails.");
@@ -204,10 +218,11 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
204
218
  const hitsPromises = matches.slice(0, limit).map((m) => __awaiter(void 0, void 0, void 0, function* () {
205
219
  var _a, _b, _c, _d;
206
220
  const user = m.user ? yield slackUserCache.get(m.user) : undefined;
221
+ const prettyText = m.text ? yield expandSlackEntities(client, slackUserCache, m.text) : undefined;
207
222
  return {
208
223
  channelId: ((_a = m.channel) === null || _a === void 0 ? void 0 : _a.id) || ((_b = m.channel) === null || _b === void 0 ? void 0 : _b.name) || "",
209
224
  ts: m.ts,
210
- text: m.text,
225
+ text: prettyText,
211
226
  userEmail: (_c = user === null || user === void 0 ? void 0 : user.email) !== null && _c !== void 0 ? _c : undefined,
212
227
  userName: (_d = user === null || user === void 0 ? void 0 : user.name) !== null && _d !== void 0 ? _d : undefined,
213
228
  };
@@ -231,19 +246,22 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
231
246
  .map((t) => __awaiter(void 0, void 0, void 0, function* () {
232
247
  var _a, _b;
233
248
  const user = t.user ? yield slackUserCache.get(t.user) : undefined;
249
+ const prettyText = t.text ? yield expandSlackEntities(client, slackUserCache, t.text) : undefined;
234
250
  return {
235
251
  ts: t.ts,
236
- text: t.text,
252
+ text: prettyText,
237
253
  userEmail: (_a = user === null || user === void 0 ? void 0 : user.email) !== null && _a !== void 0 ? _a : undefined,
238
254
  userName: (_b = user === null || user === void 0 ? void 0 : user.name) !== null && _b !== void 0 ? _b : undefined,
239
255
  };
240
256
  }));
241
257
  const context = yield Promise.all(contextPromises);
242
258
  const user = anchor.user ? yield slackUserCache.get(anchor.user) : undefined;
259
+ const textResponse = (_a = anchor.text) !== null && _a !== void 0 ? _a : h.text;
260
+ const prettyText = textResponse ? yield expandSlackEntities(client, slackUserCache, textResponse) : undefined;
243
261
  return {
244
262
  channelId: h.channelId,
245
263
  ts: rootTs,
246
- text: (_a = anchor.text) !== null && _a !== void 0 ? _a : h.text,
264
+ text: prettyText,
247
265
  userEmail: (_b = user === null || user === void 0 ? void 0 : user.email) !== null && _b !== void 0 ? _b : h.userEmail,
248
266
  userName: (_c = user === null || user === void 0 ? void 0 : user.name) !== null && _c !== void 0 ? _c : h.userName,
249
267
  context,
@@ -261,9 +279,10 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
261
279
  .map((t) => __awaiter(void 0, void 0, void 0, function* () {
262
280
  var _a, _b;
263
281
  const user = t.user ? yield slackUserCache.get(t.user) : undefined;
282
+ const prettyText = t.text ? yield expandSlackEntities(client, slackUserCache, t.text) : undefined;
264
283
  return {
265
284
  ts: t.ts,
266
- text: t.text,
285
+ text: prettyText,
267
286
  userEmail: (_a = user === null || user === void 0 ? void 0 : user.email) !== null && _a !== void 0 ? _a : undefined,
268
287
  userName: (_b = user === null || user === void 0 ? void 0 : user.name) !== null && _b !== void 0 ? _b : undefined,
269
288
  };
@@ -286,7 +305,7 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
286
305
  return {
287
306
  channelId: h.channelId,
288
307
  ts: h.ts,
289
- text: h.text,
308
+ text: h.text ? yield expandSlackEntities(client, slackUserCache, h.text) : undefined,
290
309
  userEmail: h.userEmail,
291
310
  userName: h.userName,
292
311
  permalink: yield getPermalink(client, h.channelId, h.ts),
@@ -306,6 +325,58 @@ const searchSlack = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params,
306
325
  url: r.permalink || "",
307
326
  contents: r,
308
327
  })),
328
+ currentUser,
309
329
  };
310
330
  });
331
+ function expandSlackEntities(client_1, cache_1, raw_1) {
332
+ return __awaiter(this, arguments, void 0, function* (client, cache, raw, { includeEmail = false } = {}) {
333
+ let text = raw;
334
+ // 1) Users: <@U12345> -> @Name (or @Name <email>)
335
+ const userIds = new Set();
336
+ for (const m of raw.matchAll(MENTION_USER_RE))
337
+ userIds.add(m[1]);
338
+ const idToUser = {};
339
+ yield Promise.all([...userIds].map((id) => __awaiter(this, void 0, void 0, function* () {
340
+ try {
341
+ const u = yield cache.get(id);
342
+ idToUser[id] = { name: u === null || u === void 0 ? void 0 : u.name, email: u === null || u === void 0 ? void 0 : u.email };
343
+ }
344
+ catch (_a) {
345
+ idToUser[id] = {};
346
+ }
347
+ })));
348
+ text = text.replace(MENTION_USER_RE, (_, id) => {
349
+ const u = idToUser[id];
350
+ if (u === null || u === void 0 ? void 0 : u.name) {
351
+ return includeEmail && u.email ? `@${u.name} <${u.email}>` : `@${u.name}`;
352
+ }
353
+ // fallback: keep original token if we can't resolve
354
+ return `@${id}`;
355
+ });
356
+ // 2) Channels: <#C12345|name> -> #name (fallback to #C12345)
357
+ const channelIds = new Set();
358
+ for (const m of raw.matchAll(MENTION_CHANNEL_RE))
359
+ channelIds.add(m[1]);
360
+ const idToChannel = {};
361
+ yield Promise.all([...channelIds].map((id) => __awaiter(this, void 0, void 0, function* () {
362
+ var _a, _b;
363
+ try {
364
+ const info = yield client.conversations.info({ channel: id });
365
+ idToChannel[id] = (_b = (_a = info.channel) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : undefined;
366
+ }
367
+ catch (_c) {
368
+ idToChannel[id] = undefined;
369
+ }
370
+ })));
371
+ text = text.replace(MENTION_CHANNEL_RE, (_, id) => { var _a; return `#${(_a = idToChannel[id]) !== null && _a !== void 0 ? _a : id}`; });
372
+ // 3) Special mentions: <!here>, <!channel>, <!everyone>
373
+ text = text.replace(SPECIAL_RE, (_, kind) => `@${kind}`);
374
+ // 4) User groups: <!subteam^S123|@group> -> @group (fallback to @S123)
375
+ text = text.replace(SUBTEAM_RE, (_m, sid) => `@${sid}`);
376
+ // 5) Slack links: <https://x|label> -> label (or the URL)
377
+ text = text.replace(/<([^>|]+)\|([^>]+)>/g, (_m, _url, label) => label); // keep label
378
+ text = text.replace(/<([^>|]+)>/g, (_m, url) => url); // bare <https://…>
379
+ return text;
380
+ });
381
+ }
311
382
  export default searchSlack;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.128",
3
+ "version": "0.2.130",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,
@@ -1,3 +0,0 @@
1
- import type { jiraUpdateServiceDeskRequestFunction } from "../../autogen/types.js";
2
- declare const updateServiceDeskRequest: jiraUpdateServiceDeskRequestFunction;
3
- export default updateServiceDeskRequest;
@@ -1,72 +0,0 @@
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 { axiosClient } from "../../util/axiosClient.js";
11
- const updateServiceDeskRequest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
12
- const { issueId, requestTypeId, summary, description, priority, customFields } = params;
13
- const { authToken, cloudId, baseUrl } = authParams;
14
- if (!cloudId || !authToken) {
15
- throw new Error("Valid Cloud ID and auth token are required to update service desk request");
16
- }
17
- // Use the regular Jira API for updating service desk requests as they are still Jira issues
18
- const apiUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueId}`;
19
- const formattedDescription = description
20
- ? {
21
- type: "doc",
22
- version: 1,
23
- content: [
24
- {
25
- type: "paragraph",
26
- content: [
27
- {
28
- type: "text",
29
- text: description,
30
- },
31
- ],
32
- },
33
- ],
34
- }
35
- : undefined;
36
- const payload = {
37
- fields: Object.assign(Object.assign(Object.assign(Object.assign({}, (summary && { summary })), (formattedDescription && { description: formattedDescription })), (priority && { priority: { name: priority } })), (customFields && Object.assign({}, customFields))),
38
- };
39
- try {
40
- yield axiosClient.put(apiUrl, payload, {
41
- headers: {
42
- Authorization: `Bearer ${authToken}`,
43
- Accept: "application/json",
44
- "Content-Type": "application/json",
45
- },
46
- });
47
- // Get the updated issue details to return current status and web link
48
- const getResponse = yield axiosClient.get(apiUrl, {
49
- headers: {
50
- Authorization: `Bearer ${authToken}`,
51
- Accept: "application/json",
52
- },
53
- });
54
- const issueKey = getResponse.data.key;
55
- const currentStatus = getResponse.data.fields.status.name;
56
- const webLink = `${baseUrl}/browse/${issueKey}`;
57
- return {
58
- success: true,
59
- issueKey,
60
- webLink,
61
- currentStatus,
62
- };
63
- }
64
- catch (error) {
65
- console.error("Error updating service desk request:", error);
66
- return {
67
- success: false,
68
- error: error instanceof Error ? error.message : "Unknown error",
69
- };
70
- }
71
- });
72
- export default updateServiceDeskRequest;