@credal/actions 0.2.203 → 0.2.206
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/actionMapper.js +8 -1
- package/dist/actions/autogen/templates.d.ts +3 -0
- package/dist/actions/autogen/templates.js +151 -1
- package/dist/actions/autogen/types.d.ts +97 -0
- package/dist/actions/autogen/types.js +54 -4
- package/dist/actions/providers/ashby/addCandidateToProject.d.ts +3 -0
- package/dist/actions/providers/ashby/addCandidateToProject.js +31 -0
- package/dist/actions/providers/ashby/createCandidate.d.ts +3 -0
- package/dist/actions/providers/ashby/createCandidate.js +38 -0
- package/dist/actions/providers/ashby/createNote.d.ts +3 -0
- package/dist/actions/providers/ashby/createNote.js +31 -0
- package/dist/actions/providers/ashby/getCandidateInfo.d.ts +3 -0
- package/dist/actions/providers/ashby/getCandidateInfo.js +33 -0
- package/dist/actions/providers/ashby/listCandidateNotes.d.ts +3 -0
- package/dist/actions/providers/ashby/listCandidateNotes.js +33 -0
- package/dist/actions/providers/ashby/listCandidates.d.ts +3 -0
- package/dist/actions/providers/ashby/listCandidates.js +30 -0
- package/dist/actions/providers/ashby/searchCandidates.d.ts +3 -0
- package/dist/actions/providers/ashby/searchCandidates.js +34 -0
- package/dist/actions/providers/ashby/updateCandidate.d.ts +3 -0
- package/dist/actions/providers/ashby/updateCandidate.js +56 -0
- package/dist/actions/providers/github/searchRepository.js +7 -7
- package/dist/actions/providers/gong/getGongTranscripts.d.ts +3 -0
- package/dist/actions/providers/gong/getGongTranscripts.js +315 -0
- package/dist/actions/providers/google-oauth/addTextToTopOfDoc.js +5 -13
- package/dist/actions/providers/google-oauth/createNewGoogleDoc.js +10 -123
- package/dist/actions/providers/google-oauth/utils/googleDocsMarkdown.d.ts +88 -0
- package/dist/actions/providers/google-oauth/utils/googleDocsMarkdown.js +350 -0
- package/dist/actions/providers/jamf/getJamfComputerInventory.d.ts +3 -0
- package/dist/actions/providers/jamf/getJamfComputerInventory.js +37 -0
- package/dist/actions/providers/jamf/getJamfFileVaultRecoveryKey.d.ts +3 -0
- package/dist/actions/providers/jamf/getJamfFileVaultRecoveryKey.js +39 -0
- package/dist/actions/providers/jamf/getJamfUserComputerId.d.ts +3 -0
- package/dist/actions/providers/jamf/getJamfUserComputerId.js +45 -0
- package/dist/actions/providers/jamf/lockJamfComputerById.d.ts +3 -0
- package/dist/actions/providers/jamf/lockJamfComputerById.js +39 -0
- package/dist/actions/providers/jira/commentJiraTicketWithMentions.d.ts +3 -0
- package/dist/actions/providers/jira/commentJiraTicketWithMentions.js +39 -0
- package/dist/actions/providers/jira/convertMentionsInAdf.d.ts +21 -0
- package/dist/actions/providers/jira/convertMentionsInAdf.js +125 -0
- package/dist/actions/providers/jira/updateServiceDeskRequest.d.ts +3 -0
- package/dist/actions/providers/jira/updateServiceDeskRequest.js +72 -0
- package/dist/actions/providers/jira/utils.d.ts +1 -1
- package/dist/actions/providers/jira/utils.js +1 -0
- package/dist/actions/providers/kandji/getFVRecoveryKeyForDevice.d.ts +3 -0
- package/dist/actions/providers/kandji/getFVRecoveryKeyForDevice.js +85 -0
- package/dist/actions/providers/microsoft/sendOutlookEmail.d.ts +3 -0
- package/dist/actions/providers/microsoft/sendOutlookEmail.js +48 -0
- package/dist/actions/providers/okta/addUserToGroup.d.ts +3 -0
- package/dist/actions/providers/okta/addUserToGroup.js +56 -0
- package/dist/actions/providers/okta/getOktaGroup.d.ts +3 -0
- package/dist/actions/providers/okta/getOktaGroup.js +73 -0
- package/dist/actions/providers/okta/getOktaUser.d.ts +3 -0
- package/dist/actions/providers/okta/getOktaUser.js +40 -0
- package/dist/actions/providers/okta/listMFA.d.ts +3 -0
- package/dist/actions/providers/okta/listMFA.js +52 -0
- package/dist/actions/providers/okta/listOktaGroupMembers.d.ts +3 -0
- package/dist/actions/providers/okta/listOktaGroupMembers.js +99 -0
- package/dist/actions/providers/okta/listOktaGroups.d.ts +3 -0
- package/dist/actions/providers/okta/listOktaGroups.js +92 -0
- package/dist/actions/providers/okta/listOktaUserGroups.d.ts +3 -0
- package/dist/actions/providers/okta/listOktaUserGroups.js +83 -0
- package/dist/actions/providers/okta/listOktaUsers.d.ts +3 -0
- package/dist/actions/providers/okta/listOktaUsers.js +100 -0
- package/dist/actions/providers/okta/removeUserFromGroup.d.ts +3 -0
- package/dist/actions/providers/okta/removeUserFromGroup.js +56 -0
- package/dist/actions/providers/okta/resetMFA.d.ts +3 -0
- package/dist/actions/providers/okta/resetMFA.js +62 -0
- package/dist/actions/providers/okta/resetPassword.d.ts +3 -0
- package/dist/actions/providers/okta/resetPassword.js +57 -0
- package/dist/actions/providers/okta/triggerOktaWorkflow.d.ts +3 -0
- package/dist/actions/providers/okta/triggerOktaWorkflow.js +44 -0
- package/dist/actions/providers/salesforce/executeReport.js +2 -1
- package/dist/actions/providers/salesforce/fetchSalesforceSchema.d.ts +3 -0
- package/dist/actions/providers/salesforce/fetchSalesforceSchema.js +40 -0
- package/package.json +4 -2
|
@@ -0,0 +1,45 @@
|
|
|
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 getJamfUserComputerId = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken, subdomain } = authParams;
|
|
13
|
+
const { userEmail } = params;
|
|
14
|
+
if (!subdomain || !authToken) {
|
|
15
|
+
throw new Error("Instance and authToken are required to fetch Jamf user computer ID");
|
|
16
|
+
}
|
|
17
|
+
const url = `https://${subdomain}.jamfcloud.com`;
|
|
18
|
+
try {
|
|
19
|
+
const computers = yield axiosClient.get(`${url}/api/v1/computers-inventory`, {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${authToken}`,
|
|
22
|
+
Accept: "application/json",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const filteredComputers = computers.data.results.filter(computer => { var _a; return ((_a = computer.userAndLocation) === null || _a === void 0 ? void 0 : _a.email) === userEmail; });
|
|
26
|
+
if (filteredComputers.length === 0) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
error: `No computers found for user with email: ${userEmail}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
computerId: filteredComputers[0].id,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error("Error retrieving Jamf user computer ID: ", error);
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export default getJamfUserComputerId;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 lockJamfComputerById = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { authToken, subdomain } = authParams;
|
|
13
|
+
const { computerId, passcode } = params;
|
|
14
|
+
if (!subdomain || !authToken) {
|
|
15
|
+
throw new Error("Instance and authToken are required to fetch Jamf user computer ID");
|
|
16
|
+
}
|
|
17
|
+
const url = `https://${subdomain}.jamfcloud.com`;
|
|
18
|
+
try {
|
|
19
|
+
yield axiosClient.post(`${url}/JSSResource/computercommands/command/DeviceLock/id/${computerId}`, {
|
|
20
|
+
passcode,
|
|
21
|
+
}, {
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: `Bearer ${authToken}`,
|
|
24
|
+
Accept: "application/json",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
success: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error("Error locking Jamf computer: ", error);
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export default lockJamfComputerById;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
2
|
+
import { getJiraApiConfig, getErrorMessage } from "./utils.js";
|
|
3
|
+
import { extractMentions, insertMentionNodes } from "./convertMentionsInAdf.js";
|
|
4
|
+
import { markdownToAdf } from "marklassian";
|
|
5
|
+
const commentJiraTicketWithMentions = async ({ params, authParams, }) => {
|
|
6
|
+
const { authToken } = authParams;
|
|
7
|
+
const { issueId, comment } = params;
|
|
8
|
+
try {
|
|
9
|
+
const { apiUrl, browseUrl, isDataCenter } = getJiraApiConfig(authParams);
|
|
10
|
+
if (isDataCenter) {
|
|
11
|
+
return {
|
|
12
|
+
success: false,
|
|
13
|
+
error: "commentJiraTicketWithMentions is only supported on Jira Cloud. Use commentJiraTicket for Jira Data Center.",
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const { sanitized, mentions } = extractMentions(comment);
|
|
17
|
+
const adf = markdownToAdf(sanitized);
|
|
18
|
+
const body = insertMentionNodes(adf, mentions);
|
|
19
|
+
const response = await axiosClient.post(`${apiUrl}/issue/${issueId}/comment`, { body }, {
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${authToken}`,
|
|
22
|
+
Accept: "application/json",
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
success: true,
|
|
28
|
+
commentUrl: `${browseUrl}/browse/${issueId}?focusedCommentId=${response.data.id}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error("Error commenting on Jira ticket with mentions: ", error);
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
error: getErrorMessage(error),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export default commentJiraTicketWithMentions;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts [~accountid:XXXXX] patterns from raw text and replaces them with
|
|
3
|
+
* safe placeholders that won't be mangled by markdown parsers.
|
|
4
|
+
*
|
|
5
|
+
* Use with {@link insertMentionNodes} after markdown-to-ADF conversion.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractMentions(text: string): {
|
|
8
|
+
sanitized: string;
|
|
9
|
+
mentions: string[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Walks an ADF tree and replaces placeholder tokens (produced by
|
|
13
|
+
* {@link extractMentions}) with proper ADF mention nodes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function insertMentionNodes(adf: unknown, mentions: string[]): unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Walks an ADF tree and converts raw [~accountid:XXXXX] text patterns into
|
|
18
|
+
* ADF mention nodes. Works reliably for single mentions per paragraph; for
|
|
19
|
+
* multiple mentions use extractMentions + insertMentionNodes instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare function convertMentionsInAdf(adf: unknown): unknown;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const JIRA_MENTION_SOURCE = "\\[~accountid:([^\\]]+)\\]";
|
|
2
|
+
const JIRA_MENTION_TEST = new RegExp(JIRA_MENTION_SOURCE);
|
|
3
|
+
const PLACEHOLDER_PREFIX = "\uFFFCMENTION_";
|
|
4
|
+
const PLACEHOLDER_SUFFIX = "\uFFFC";
|
|
5
|
+
/**
|
|
6
|
+
* Extracts [~accountid:XXXXX] patterns from raw text and replaces them with
|
|
7
|
+
* safe placeholders that won't be mangled by markdown parsers.
|
|
8
|
+
*
|
|
9
|
+
* Use with {@link insertMentionNodes} after markdown-to-ADF conversion.
|
|
10
|
+
*/
|
|
11
|
+
export function extractMentions(text) {
|
|
12
|
+
const mentions = [];
|
|
13
|
+
const sanitized = text.replace(new RegExp(JIRA_MENTION_SOURCE, "g"), (_match, id) => {
|
|
14
|
+
const index = mentions.length;
|
|
15
|
+
mentions.push(id);
|
|
16
|
+
return `${PLACEHOLDER_PREFIX}${index}${PLACEHOLDER_SUFFIX}`;
|
|
17
|
+
});
|
|
18
|
+
return { sanitized, mentions };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Walks an ADF tree and replaces placeholder tokens (produced by
|
|
22
|
+
* {@link extractMentions}) with proper ADF mention nodes.
|
|
23
|
+
*/
|
|
24
|
+
export function insertMentionNodes(adf, mentions) {
|
|
25
|
+
if (mentions.length === 0)
|
|
26
|
+
return adf;
|
|
27
|
+
const placeholderRegex = new RegExp(`${escapeRegex(PLACEHOLDER_PREFIX)}(\\d+)${escapeRegex(PLACEHOLDER_SUFFIX)}`);
|
|
28
|
+
return walkAndReplace(adf, placeholderRegex, mentions);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Walks an ADF tree and converts raw [~accountid:XXXXX] text patterns into
|
|
32
|
+
* ADF mention nodes. Works reliably for single mentions per paragraph; for
|
|
33
|
+
* multiple mentions use extractMentions + insertMentionNodes instead.
|
|
34
|
+
*/
|
|
35
|
+
export function convertMentionsInAdf(adf) {
|
|
36
|
+
if (!adf || typeof adf !== "object")
|
|
37
|
+
return adf;
|
|
38
|
+
if (Array.isArray(adf))
|
|
39
|
+
return adf.flatMap(item => {
|
|
40
|
+
const result = convertMentionsInAdf(item);
|
|
41
|
+
return Array.isArray(result) ? result : [result];
|
|
42
|
+
});
|
|
43
|
+
const node = adf;
|
|
44
|
+
if (node.type === "text" && typeof node.text === "string" && JIRA_MENTION_TEST.test(node.text)) {
|
|
45
|
+
return splitTextNodeWithMentions(node, new RegExp(JIRA_MENTION_SOURCE, "g"), (_match, groups) => groups[0]);
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(node.content)) {
|
|
48
|
+
const newContent = [];
|
|
49
|
+
for (const child of node.content) {
|
|
50
|
+
const result = convertMentionsInAdf(child);
|
|
51
|
+
if (Array.isArray(result)) {
|
|
52
|
+
newContent.push(...result);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
newContent.push(result);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { ...node, content: newContent };
|
|
59
|
+
}
|
|
60
|
+
return node;
|
|
61
|
+
}
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Internal helpers
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
function walkAndReplace(adf, regex, mentions) {
|
|
66
|
+
if (!adf || typeof adf !== "object")
|
|
67
|
+
return adf;
|
|
68
|
+
if (Array.isArray(adf))
|
|
69
|
+
return adf.flatMap(item => {
|
|
70
|
+
const result = walkAndReplace(item, regex, mentions);
|
|
71
|
+
return Array.isArray(result) ? result : [result];
|
|
72
|
+
});
|
|
73
|
+
const node = adf;
|
|
74
|
+
if (node.type === "text" && typeof node.text === "string" && regex.test(node.text)) {
|
|
75
|
+
return splitTextNodeWithMentions(node, new RegExp(`${escapeRegex(PLACEHOLDER_PREFIX)}(\\d+)${escapeRegex(PLACEHOLDER_SUFFIX)}`, "g"), (_match, groups) => mentions[parseInt(groups[0], 10)]);
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(node.content)) {
|
|
78
|
+
const newContent = [];
|
|
79
|
+
for (const child of node.content) {
|
|
80
|
+
const result = walkAndReplace(child, regex, mentions);
|
|
81
|
+
if (Array.isArray(result)) {
|
|
82
|
+
newContent.push(...result);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
newContent.push(result);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return { ...node, content: newContent };
|
|
89
|
+
}
|
|
90
|
+
return node;
|
|
91
|
+
}
|
|
92
|
+
function splitTextNodeWithMentions(node, regex, resolveId) {
|
|
93
|
+
const text = node.text;
|
|
94
|
+
const marks = node.marks;
|
|
95
|
+
const results = [];
|
|
96
|
+
let lastIndex = 0;
|
|
97
|
+
let match;
|
|
98
|
+
while ((match = regex.exec(text)) !== null) {
|
|
99
|
+
if (match.index > lastIndex) {
|
|
100
|
+
const textNode = { type: "text", text: text.slice(lastIndex, match.index) };
|
|
101
|
+
if (marks)
|
|
102
|
+
textNode.marks = marks;
|
|
103
|
+
results.push(textNode);
|
|
104
|
+
}
|
|
105
|
+
results.push({
|
|
106
|
+
type: "mention",
|
|
107
|
+
attrs: {
|
|
108
|
+
id: resolveId(match[0], match.slice(1)),
|
|
109
|
+
text: `@${resolveId(match[0], match.slice(1))}`,
|
|
110
|
+
accessLevel: "",
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
lastIndex = match.index + match[0].length;
|
|
114
|
+
}
|
|
115
|
+
if (lastIndex < text.length) {
|
|
116
|
+
const textNode = { type: "text", text: text.slice(lastIndex) };
|
|
117
|
+
if (marks)
|
|
118
|
+
textNode.marks = marks;
|
|
119
|
+
results.push(textNode);
|
|
120
|
+
}
|
|
121
|
+
return results;
|
|
122
|
+
}
|
|
123
|
+
function escapeRegex(str) {
|
|
124
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
125
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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;
|
|
@@ -70,5 +70,5 @@ export declare function getUserInfoFromAccountId(accountId: string | undefined,
|
|
|
70
70
|
name: string | undefined;
|
|
71
71
|
email: string | undefined;
|
|
72
72
|
} | null>;
|
|
73
|
+
export { convertMentionsInAdf } from "./convertMentionsInAdf.js";
|
|
73
74
|
export declare function extractPlainText(adf: unknown): string;
|
|
74
|
-
export {};
|
|
@@ -200,6 +200,7 @@ export async function getUserInfoFromAccountId(accountId, client) {
|
|
|
200
200
|
return null;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
+
export { convertMentionsInAdf } from "./convertMentionsInAdf.js";
|
|
203
204
|
export function extractPlainText(adf) {
|
|
204
205
|
if (!adf || typeof adf !== "object")
|
|
205
206
|
return "";
|
|
@@ -0,0 +1,85 @@
|
|
|
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 getFVRecoveryKeyForDevice = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { userEmail, subdomain } = params;
|
|
13
|
+
const { apiKey } = authParams;
|
|
14
|
+
if (!apiKey) {
|
|
15
|
+
throw new Error("Missing API key in auth parameters");
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
// First list all devices to get the device for the specific device
|
|
19
|
+
const device = yield getDeviceByEmail({
|
|
20
|
+
apiKey,
|
|
21
|
+
userEmail,
|
|
22
|
+
subdomain,
|
|
23
|
+
});
|
|
24
|
+
if (!device) {
|
|
25
|
+
return {
|
|
26
|
+
success: false,
|
|
27
|
+
error: "Device not found for the given serial number",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Then get the FV recovery key for that device
|
|
31
|
+
const fvRecoveryKey = yield axiosClient.get(`https://${subdomain}.api.kandji.io/api/v1/devices/${device.device_id}/secrets/filevaultkey`, {
|
|
32
|
+
headers: {
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
Authorization: `Bearer ${apiKey}`,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
if (!fvRecoveryKey || !fvRecoveryKey.data || !fvRecoveryKey.data.key) {
|
|
38
|
+
return {
|
|
39
|
+
success: false,
|
|
40
|
+
error: "FireVault recovery key not found",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
recoveryKey: fvRecoveryKey.data.key,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
function getDeviceByEmail(input) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const limit = 300;
|
|
58
|
+
let offset = 0;
|
|
59
|
+
const { apiKey, userEmail, subdomain } = input;
|
|
60
|
+
while (true) {
|
|
61
|
+
// Update params
|
|
62
|
+
const params = { limit, offset };
|
|
63
|
+
const endpoint = `https://${subdomain}.api.kandji.io/api/v1/devices`;
|
|
64
|
+
const response = yield axiosClient.get(endpoint, {
|
|
65
|
+
params: Object.assign({}, params),
|
|
66
|
+
headers: {
|
|
67
|
+
"Content-Type": "application/json",
|
|
68
|
+
Authorization: `Bearer ${apiKey}`,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
for (const device of response.data) {
|
|
72
|
+
if (device.user && device.user.email === userEmail) {
|
|
73
|
+
// If the device user email matches, return the device
|
|
74
|
+
return device;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
offset += limit;
|
|
78
|
+
if (response.data.length === 0) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export default getFVRecoveryKeyForDevice;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { getGraphClient } from "./utils.js";
|
|
11
|
+
const sendEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
|
12
|
+
const { toRecipients, subject, body, ccRecipients, bccRecipients } = params;
|
|
13
|
+
let client = undefined;
|
|
14
|
+
try {
|
|
15
|
+
client = yield getGraphClient(authParams);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return {
|
|
19
|
+
success: false,
|
|
20
|
+
error: "Error while authorizing: " + (error instanceof Error ? error.message : "Unknown error"),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const message = {
|
|
25
|
+
message: Object.assign(Object.assign({ subject, body: {
|
|
26
|
+
contentType: "HTML",
|
|
27
|
+
content: body,
|
|
28
|
+
}, toRecipients: toRecipients.map(email => ({ emailAddress: { address: email } })) }, (ccRecipients && ccRecipients.length > 0
|
|
29
|
+
? { ccRecipients: ccRecipients.map(email => ({ emailAddress: { address: email } })) }
|
|
30
|
+
: {})), (bccRecipients && bccRecipients.length > 0
|
|
31
|
+
? { bccRecipients: bccRecipients.map(email => ({ emailAddress: { address: email } })) }
|
|
32
|
+
: {})),
|
|
33
|
+
saveToSentItems: true,
|
|
34
|
+
};
|
|
35
|
+
yield client.api("/me/sendMail").post(message);
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error(error);
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
error: "Error sending email: " + (error instanceof Error ? error.message : "Unknown error"),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export default sendEmail;
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { AxiosError } from "axios";
|
|
11
|
+
import { axiosClient } from "../../util/axiosClient.js";
|
|
12
|
+
const addUserToGroup = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, params, }) {
|
|
13
|
+
var _b, _c;
|
|
14
|
+
const { authToken, baseUrl } = authParams;
|
|
15
|
+
if (!authToken || !baseUrl) {
|
|
16
|
+
return {
|
|
17
|
+
success: false,
|
|
18
|
+
error: "Missing Okta OAuth token (authToken) or base URL (baseUrl) in authParams.",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const requestConfig = {
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${authToken}`,
|
|
25
|
+
Accept: "application/json",
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const endpointUrl = new URL(`/api/v1/groups/${params.groupId}/users/${params.userId}`, baseUrl).toString();
|
|
30
|
+
const response = yield axiosClient.put(endpointUrl, {}, requestConfig);
|
|
31
|
+
if (response.status === 204) {
|
|
32
|
+
return { success: true };
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const errorDetail = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.errorSummary) || ((_c = response.data) === null || _c === void 0 ? void 0 : _c.message) || `Okta API responded with status ${response.status}`;
|
|
36
|
+
return { success: false, error: `Failed to add user to group: ${errorDetail}` };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error("Error adding user to group:", error);
|
|
41
|
+
let errorMessage = "Unknown error while adding user to group";
|
|
42
|
+
if (error instanceof AxiosError && error.response) {
|
|
43
|
+
const oktaError = error.response.data;
|
|
44
|
+
errorMessage =
|
|
45
|
+
(oktaError === null || oktaError === void 0 ? void 0 : oktaError.errorSummary) || (oktaError === null || oktaError === void 0 ? void 0 : oktaError.message) || `Okta API request failed with status ${error.response.status}`;
|
|
46
|
+
}
|
|
47
|
+
else if (error instanceof Error) {
|
|
48
|
+
errorMessage = error.message;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
error: errorMessage,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
export default addUserToGroup;
|