@credal/actions 0.2.188 → 0.2.189
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/autogen/templates.js +7 -0
- package/dist/actions/autogen/types.d.ts +3 -0
- package/dist/actions/autogen/types.js +4 -0
- package/dist/actions/groups.js +1 -14
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +3 -0
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.js +43 -0
- package/dist/actions/providers/slack/archiveChannel.js +2 -9
- package/dist/actions/providers/slackUser/searchSlackRTS.js +40 -2
- package/package.json +1 -1
- package/dist/actions/providers/confluence/updatePage.d.ts +0 -3
- package/dist/actions/providers/confluence/updatePage.js +0 -47
- package/dist/actions/providers/jamf/types.d.ts +0 -8
- package/dist/actions/providers/jamf/types.js +0 -7
|
@@ -1074,6 +1074,13 @@ export const slackUserSearchSlackRTSDefinition = {
|
|
|
1074
1074
|
type: "string",
|
|
1075
1075
|
description: 'The search query string (e.g., "What is project gizmo?", "mobile UX revamp"). You can use any Slack filters directly in the query string.',
|
|
1076
1076
|
},
|
|
1077
|
+
userEmails: {
|
|
1078
|
+
type: "array",
|
|
1079
|
+
description: 'Optional. Users to filter messages from. Each value should be a plain-text email (e.g. "user@company.com"). Will be resolved to a Slack user ID and formatted into the query as from:<@U...>.',
|
|
1080
|
+
items: {
|
|
1081
|
+
type: "string",
|
|
1082
|
+
},
|
|
1083
|
+
},
|
|
1077
1084
|
channelTypes: {
|
|
1078
1085
|
type: "array",
|
|
1079
1086
|
description: "Filter by channel types to search. If not specified, searches all channel types the user has access to.",
|
|
@@ -1317,6 +1317,7 @@ export type slackUserSearchSlackOutputType = z.infer<typeof slackUserSearchSlack
|
|
|
1317
1317
|
export type slackUserSearchSlackFunction = ActionFunction<slackUserSearchSlackParamsType, AuthParamsType, slackUserSearchSlackOutputType>;
|
|
1318
1318
|
export declare const slackUserSearchSlackRTSParamsSchema: z.ZodObject<{
|
|
1319
1319
|
query: z.ZodString;
|
|
1320
|
+
userEmails: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1320
1321
|
channelTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["public_channel", "private_channel", "mpim", "im"]>, "many">>;
|
|
1321
1322
|
contentTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<["messages", "files", "channels"]>, "many">>;
|
|
1322
1323
|
includeBots: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -1330,12 +1331,14 @@ export declare const slackUserSearchSlackRTSParamsSchema: z.ZodObject<{
|
|
|
1330
1331
|
contentTypes: ("messages" | "files" | "channels")[];
|
|
1331
1332
|
includeBots: boolean;
|
|
1332
1333
|
includeContextMessages: boolean;
|
|
1334
|
+
userEmails?: string[] | undefined;
|
|
1333
1335
|
channelTypes?: ("im" | "public_channel" | "private_channel" | "mpim")[] | undefined;
|
|
1334
1336
|
before?: string | undefined;
|
|
1335
1337
|
after?: string | undefined;
|
|
1336
1338
|
}, {
|
|
1337
1339
|
query: string;
|
|
1338
1340
|
limit?: number | undefined;
|
|
1341
|
+
userEmails?: string[] | undefined;
|
|
1339
1342
|
channelTypes?: ("im" | "public_channel" | "private_channel" | "mpim")[] | undefined;
|
|
1340
1343
|
contentTypes?: ("messages" | "files" | "channels")[] | undefined;
|
|
1341
1344
|
includeBots?: boolean | undefined;
|
|
@@ -529,6 +529,10 @@ export const slackUserSearchSlackRTSParamsSchema = z.object({
|
|
|
529
529
|
query: z
|
|
530
530
|
.string()
|
|
531
531
|
.describe('The search query string (e.g., "What is project gizmo?", "mobile UX revamp"). You can use any Slack filters directly in the query string.'),
|
|
532
|
+
userEmails: z
|
|
533
|
+
.array(z.string())
|
|
534
|
+
.describe('Optional. Users to filter messages from. Each value should be a plain-text email (e.g. "user@company.com"). Will be resolved to a Slack user ID and formatted into the query as from:<@U...>.')
|
|
535
|
+
.optional(),
|
|
532
536
|
channelTypes: z
|
|
533
537
|
.array(z.enum(["public_channel", "private_channel", "mpim", "im"]))
|
|
534
538
|
.describe("Filter by channel types to search. If not specified, searches all channel types the user has access to.")
|
package/dist/actions/groups.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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, 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, } from "./autogen/templates.js";
|
|
2
2
|
export const ACTION_GROUPS = {
|
|
3
3
|
GENERIC: {
|
|
4
4
|
description: "Generic utility actions",
|
|
@@ -47,7 +47,6 @@ export const ACTION_GROUPS = {
|
|
|
47
47
|
googleOauthUpdatePresentationDefinition,
|
|
48
48
|
googleOauthSearchDriveByKeywordsDefinition,
|
|
49
49
|
googleOauthSearchDriveByQueryDefinition,
|
|
50
|
-
googleOauthSearchDriveByQueryAndGetFileContentDefinition,
|
|
51
50
|
googleOauthGetDriveFileContentByIdDefinition,
|
|
52
51
|
],
|
|
53
52
|
},
|
|
@@ -199,8 +198,6 @@ export const ACTION_GROUPS = {
|
|
|
199
198
|
githubCreateBranchDefinition,
|
|
200
199
|
githubCreatePullRequestDefinition,
|
|
201
200
|
githubListPullRequestsDefinition,
|
|
202
|
-
githubGetFileContentDefinition,
|
|
203
|
-
githubListDirectoryDefinition,
|
|
204
201
|
],
|
|
205
202
|
},
|
|
206
203
|
ASHBY: {
|
|
@@ -248,14 +245,4 @@ export const ACTION_GROUPS = {
|
|
|
248
245
|
oktaTriggerOktaWorkflowDefinition,
|
|
249
246
|
],
|
|
250
247
|
},
|
|
251
|
-
LINEAR: {
|
|
252
|
-
description: "Actions for interacting with Linear",
|
|
253
|
-
actions: [
|
|
254
|
-
linearGetIssueDetailsDefinition,
|
|
255
|
-
linearGetProjectsDefinition,
|
|
256
|
-
linearGetProjectDetailsDefinition,
|
|
257
|
-
linearGetTeamDetailsDefinition,
|
|
258
|
-
linearGetTeamsDefinition,
|
|
259
|
-
],
|
|
260
|
-
},
|
|
261
248
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const axiosClient_1 = require("../../util/axiosClient");
|
|
13
|
+
const getSalesforceRecordByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
14
|
+
const { authToken, baseUrl } = authParams;
|
|
15
|
+
const { query, limit } = params;
|
|
16
|
+
if (!authToken || !baseUrl) {
|
|
17
|
+
return {
|
|
18
|
+
success: false,
|
|
19
|
+
error: "authToken and baseUrl are required for Salesforce API",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// The API limits the maximum number of records returned to 2000, the limit lets the user set a smaller custom limit
|
|
23
|
+
const url = `${baseUrl}/services/data/v56.0/query/?q=${encodeURIComponent(query + " LIMIT " + (limit != undefined && limit <= 2000 ? limit : 2000))}`;
|
|
24
|
+
try {
|
|
25
|
+
const response = yield axiosClient_1.axiosClient.get(url, {
|
|
26
|
+
headers: {
|
|
27
|
+
Authorization: `Bearer ${authToken}`,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
success: true,
|
|
32
|
+
records: response.data,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error("Error retrieving Salesforce record:", error);
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
exports.default = getSalesforceRecordByQuery;
|
|
@@ -9,21 +9,14 @@ 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";
|
|
13
12
|
const archiveChannel = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
14
13
|
if (!authParams.authToken) {
|
|
15
14
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
16
15
|
}
|
|
17
16
|
try {
|
|
18
17
|
const client = new WebClient(authParams.authToken);
|
|
19
|
-
const {
|
|
20
|
-
const
|
|
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 });
|
|
18
|
+
const { channelId } = params;
|
|
19
|
+
const result = yield client.conversations.archive({ channel: channelId });
|
|
27
20
|
if (!result.ok) {
|
|
28
21
|
return {
|
|
29
22
|
success: false,
|
|
@@ -9,16 +9,54 @@ 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
|
+
/* ===================== Types ===================== */
|
|
13
|
+
function resolveSlackUserId(client, raw) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
var _a;
|
|
16
|
+
const s = raw.trim();
|
|
17
|
+
if (!s)
|
|
18
|
+
return null;
|
|
19
|
+
try {
|
|
20
|
+
const res = yield client.users.lookupByEmail({ email: s });
|
|
21
|
+
if ((_a = res.user) === null || _a === void 0 ? void 0 : _a.id)
|
|
22
|
+
return res.user.id;
|
|
23
|
+
}
|
|
24
|
+
catch (_b) {
|
|
25
|
+
// ignore and fall back
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function appendToQuery(query, suffix) {
|
|
31
|
+
const q = query.trim();
|
|
32
|
+
const s = suffix.trim();
|
|
33
|
+
if (!q)
|
|
34
|
+
return s;
|
|
35
|
+
if (!s)
|
|
36
|
+
return q;
|
|
37
|
+
return `${q} ${s}`;
|
|
38
|
+
}
|
|
12
39
|
/* ===================== MAIN EXPORT ===================== */
|
|
13
40
|
const searchSlackRTS = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
14
41
|
var _b, _c;
|
|
15
42
|
if (!authParams.authToken)
|
|
16
43
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
17
44
|
const client = new WebClient(authParams.authToken);
|
|
18
|
-
const { query, channelTypes, contentTypes = ["messages", "files", "channels"], includeBots = false, limit = 20, includeContextMessages = true, before, after, } = params;
|
|
45
|
+
const { query, userEmails, channelTypes, contentTypes = ["messages", "files", "channels"], includeBots = false, limit = 20, includeContextMessages = true, before, after, } = params;
|
|
46
|
+
let finalQuery = query;
|
|
47
|
+
if (userEmails != undefined && userEmails.length > 0) {
|
|
48
|
+
const settled = yield Promise.allSettled(userEmails.map((u) => resolveSlackUserId(client, u)));
|
|
49
|
+
const fulfilled = settled.filter((r) => r.status === "fulfilled");
|
|
50
|
+
const ids = fulfilled.map(r => r.value).filter((id) => Boolean(id));
|
|
51
|
+
if (ids.length > 0) {
|
|
52
|
+
// Slack expects IDs in angle brackets, e.g. from:<@U123> from:<@U456>
|
|
53
|
+
const filter = ids.map(id => `from:<@${id}>`).join(" ");
|
|
54
|
+
finalQuery = appendToQuery(finalQuery, filter);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
19
57
|
// Build the request parameters for assistant.search.context
|
|
20
58
|
const requestParams = {
|
|
21
|
-
query,
|
|
59
|
+
query: finalQuery,
|
|
22
60
|
};
|
|
23
61
|
// Add optional parameters if provided
|
|
24
62
|
if (channelTypes && channelTypes.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
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;
|