@credal/actions 0.2.25 → 0.2.27
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 +7 -1
- package/dist/actions/autogen/templates.d.ts +1 -0
- package/dist/actions/autogen/templates.js +235 -0
- package/dist/actions/autogen/types.d.ts +288 -12
- package/dist/actions/autogen/types.js +64 -0
- package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
- package/dist/actions/providers/confluence/updatePage.js +47 -0
- package/dist/actions/providers/github/searchRepository.d.ts +3 -0
- package/dist/actions/providers/github/searchRepository.js +131 -0
- package/package.json +2 -1
- package/dist/actions/providers/google-oauth/listGmailThreads.d.ts +0 -3
- package/dist/actions/providers/google-oauth/listGmailThreads.js +0 -98
- package/dist/actions/providers/google-oauth/searchGmailMessages.d.ts +0 -3
- package/dist/actions/providers/google-oauth/searchGmailMessages.js +0 -91
- package/dist/actions/providers/jamf/getComputerInventory.d.ts +0 -3
- package/dist/actions/providers/jamf/getComputerInventory.js +0 -45
- package/dist/actions/providers/jamf/getFileVaultRecoveryKey.d.ts +0 -3
- package/dist/actions/providers/jamf/getFileVaultRecoveryKey.js +0 -40
- package/dist/actions/providers/jamf/restartJamfComputerById.d.ts +0 -3
- package/dist/actions/providers/jamf/restartJamfComputerById.js +0 -37
@@ -0,0 +1,131 @@
|
|
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 { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
|
11
|
+
// Limits on the number of results to return
|
12
|
+
const MAX_CODE_RESULTS = 15;
|
13
|
+
const MAX_COMMITS = 10;
|
14
|
+
const MAX_FILES_PER_COMMIT = 5;
|
15
|
+
const MAX_ISSUES_OR_PRS = 10;
|
16
|
+
const MAX_FILES_PER_PR = 5;
|
17
|
+
const MAX_PATCH_LINES = 20;
|
18
|
+
const MAX_FRAGMENT_LINES = 20;
|
19
|
+
const searchRepository = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
20
|
+
const { getOctokit } = yield import("@actions/github");
|
21
|
+
if (!authParams.authToken) {
|
22
|
+
throw new Error(MISSING_AUTH_TOKEN);
|
23
|
+
}
|
24
|
+
const octokit = getOctokit(authParams.authToken);
|
25
|
+
const { organization, repository, query } = params;
|
26
|
+
// Search CODE with text match metadata
|
27
|
+
const codeResultsResponse = yield octokit.rest.search.code({
|
28
|
+
q: `${query} repo:${organization}/${repository}`,
|
29
|
+
text_match: true,
|
30
|
+
headers: {
|
31
|
+
accept: "application/vnd.github.v3.text-match+json",
|
32
|
+
},
|
33
|
+
});
|
34
|
+
const codeResults = codeResultsResponse.data.items.slice(0, MAX_CODE_RESULTS).map(item => ({
|
35
|
+
name: item.name,
|
36
|
+
path: item.path,
|
37
|
+
sha: item.sha,
|
38
|
+
url: item.url,
|
39
|
+
repository: {
|
40
|
+
full_name: item.repository.full_name,
|
41
|
+
html_url: item.repository.html_url,
|
42
|
+
},
|
43
|
+
score: item.score,
|
44
|
+
textMatches: item.text_matches
|
45
|
+
? item.text_matches.map(match => {
|
46
|
+
var _a, _b, _c, _d;
|
47
|
+
return ({
|
48
|
+
object_url: (_a = match.object_url) !== null && _a !== void 0 ? _a : undefined,
|
49
|
+
object_type: (_b = match.object_type) !== null && _b !== void 0 ? _b : undefined,
|
50
|
+
fragment: (_c = match.fragment) === null || _c === void 0 ? void 0 : _c.split("\n").slice(0, MAX_FRAGMENT_LINES).join("\n"),
|
51
|
+
matches: (_d = match.matches) !== null && _d !== void 0 ? _d : [],
|
52
|
+
});
|
53
|
+
})
|
54
|
+
: [],
|
55
|
+
}));
|
56
|
+
// Search COMMITS
|
57
|
+
const commitResults = yield octokit.rest.search.commits({
|
58
|
+
q: `${query} repo:${organization}/${repository}`,
|
59
|
+
headers: {
|
60
|
+
accept: "application/vnd.github.cloak-preview+json",
|
61
|
+
},
|
62
|
+
});
|
63
|
+
const commitSHAs = commitResults.data.items.slice(0, MAX_COMMITS).map(item => item.sha);
|
64
|
+
const commitDetails = yield Promise.all(commitSHAs.map(sha => octokit.rest.repos.getCommit({ owner: organization, repo: repository, ref: sha })));
|
65
|
+
const enrichedCommits = commitResults.data.items.slice(0, MAX_COMMITS).map(item => {
|
66
|
+
var _a, _b;
|
67
|
+
const full = commitDetails.find(c => c.data.sha === item.sha);
|
68
|
+
return {
|
69
|
+
sha: item.sha,
|
70
|
+
url: item.url,
|
71
|
+
commit: {
|
72
|
+
message: item.commit.message,
|
73
|
+
author: item.commit.author,
|
74
|
+
},
|
75
|
+
score: item.score,
|
76
|
+
author: (_a = item.author) !== null && _a !== void 0 ? _a : undefined,
|
77
|
+
files: ((_b = full === null || full === void 0 ? void 0 : full.data.files) === null || _b === void 0 ? void 0 : _b.slice(0, MAX_FILES_PER_COMMIT).map(f => {
|
78
|
+
var _a;
|
79
|
+
return ({
|
80
|
+
filename: f.filename,
|
81
|
+
status: f.status,
|
82
|
+
patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
|
83
|
+
});
|
84
|
+
})) || [],
|
85
|
+
};
|
86
|
+
});
|
87
|
+
// Search ISSUES & PRs
|
88
|
+
const issueResults = yield octokit.rest.search.issuesAndPullRequests({
|
89
|
+
q: `${query} repo:${organization}/${repository}`,
|
90
|
+
});
|
91
|
+
const prItems = issueResults.data.items.filter(item => item.pull_request).slice(0, MAX_ISSUES_OR_PRS);
|
92
|
+
const prNumbers = prItems.map(item => item.number);
|
93
|
+
const prFiles = yield Promise.all(prNumbers.map(number => octokit.rest.pulls.listFiles({ owner: organization, repo: repository, pull_number: number })));
|
94
|
+
const issuesAndPRs = issueResults.data.items
|
95
|
+
.slice(0, MAX_ISSUES_OR_PRS)
|
96
|
+
.map(item => {
|
97
|
+
var _a, _b, _c, _d;
|
98
|
+
const isPR = !!item.pull_request;
|
99
|
+
const prIndex = prNumbers.indexOf(item.number);
|
100
|
+
const files = isPR && prIndex !== -1
|
101
|
+
? prFiles[prIndex].data.slice(0, MAX_FILES_PER_PR).map(f => {
|
102
|
+
var _a;
|
103
|
+
return ({
|
104
|
+
filename: f.filename,
|
105
|
+
status: f.status,
|
106
|
+
patch: (_a = f.patch) === null || _a === void 0 ? void 0 : _a.split("\n").slice(0, MAX_PATCH_LINES).join("\n"),
|
107
|
+
});
|
108
|
+
})
|
109
|
+
: undefined;
|
110
|
+
return {
|
111
|
+
number: item.number,
|
112
|
+
title: item.title,
|
113
|
+
html_url: item.html_url,
|
114
|
+
state: item.state,
|
115
|
+
isPullRequest: isPR,
|
116
|
+
body: item.body,
|
117
|
+
user: {
|
118
|
+
email: (_b = (_a = item.user) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : undefined,
|
119
|
+
name: (_d = (_c = item.user) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : undefined,
|
120
|
+
},
|
121
|
+
score: item.score,
|
122
|
+
files,
|
123
|
+
};
|
124
|
+
});
|
125
|
+
return {
|
126
|
+
code: codeResults,
|
127
|
+
commits: enrichedCommits,
|
128
|
+
issuesAndPullRequests: issuesAndPRs,
|
129
|
+
};
|
130
|
+
});
|
131
|
+
export default searchRepository;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@credal/actions",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.27",
|
4
4
|
"type": "module",
|
5
5
|
"description": "AI Actions by Credal AI",
|
6
6
|
"sideEffects": false,
|
@@ -46,6 +46,7 @@
|
|
46
46
|
"typescript-eslint": "^8.18.0"
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
|
+
"@actions/github": "^6.0.1",
|
49
50
|
"@credal/sdk": "^0.0.21",
|
50
51
|
"@mendable/firecrawl-js": "^1.24.0",
|
51
52
|
"@microsoft/microsoft-graph-client": "^3.0.7",
|
@@ -1,98 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
-
const missingAuthConstants_1 = require("../../util/missingAuthConstants");
|
14
|
-
const decodeMessage_1 = require("./utils/decodeMessage");
|
15
|
-
const listGmailThreads = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
16
|
-
if (!authParams.authToken) {
|
17
|
-
return { success: false, error: missingAuthConstants_1.MISSING_AUTH_TOKEN, threads: [] };
|
18
|
-
}
|
19
|
-
const { query, maxResults } = params;
|
20
|
-
const allThreads = [];
|
21
|
-
const errorMessages = [];
|
22
|
-
const max = maxResults !== null && maxResults !== void 0 ? maxResults : 100;
|
23
|
-
let fetched = 0;
|
24
|
-
let pageToken = undefined;
|
25
|
-
try {
|
26
|
-
while (fetched < max) {
|
27
|
-
const url = `https://gmail.googleapis.com/gmail/v1/users/me/threads?q=${encodeURIComponent(query)}` +
|
28
|
-
(pageToken ? `&pageToken=${encodeURIComponent(pageToken)}` : "") +
|
29
|
-
`&maxResults=${Math.min(100, max - fetched)}`;
|
30
|
-
const listRes = yield axiosClient_1.axiosClient.get(url, {
|
31
|
-
headers: {
|
32
|
-
Authorization: `Bearer ${authParams.authToken}`,
|
33
|
-
},
|
34
|
-
});
|
35
|
-
const { threads: threadList = [], nextPageToken } = listRes.data;
|
36
|
-
if (!Array.isArray(threadList) || threadList.length === 0)
|
37
|
-
break;
|
38
|
-
const remaining = max - allThreads.length;
|
39
|
-
const batch = threadList.slice(0, remaining);
|
40
|
-
const results = yield Promise.all(batch.map((thread) => __awaiter(void 0, void 0, void 0, function* () {
|
41
|
-
try {
|
42
|
-
const threadRes = yield axiosClient_1.axiosClient.get(`https://gmail.googleapis.com/gmail/v1/users/me/threads/${thread.id}?format=full`, {
|
43
|
-
headers: {
|
44
|
-
Authorization: `Bearer ${authParams.authToken}`,
|
45
|
-
},
|
46
|
-
});
|
47
|
-
const { id, historyId, messages } = threadRes.data;
|
48
|
-
return {
|
49
|
-
id,
|
50
|
-
historyId,
|
51
|
-
messages: Array.isArray(messages)
|
52
|
-
? messages.map(msg => {
|
53
|
-
const { id, threadId, snippet, labelIds, internalDate } = msg;
|
54
|
-
const emailBody = (0, decodeMessage_1.getEmailContent)(msg) || "";
|
55
|
-
return {
|
56
|
-
id,
|
57
|
-
threadId,
|
58
|
-
snippet,
|
59
|
-
labelIds,
|
60
|
-
internalDate,
|
61
|
-
emailBody,
|
62
|
-
};
|
63
|
-
})
|
64
|
-
: [],
|
65
|
-
};
|
66
|
-
}
|
67
|
-
catch (err) {
|
68
|
-
errorMessages.push(err instanceof Error ? err.message : "Failed to fetch thread details");
|
69
|
-
return {
|
70
|
-
id: thread.id,
|
71
|
-
snippet: "",
|
72
|
-
historyId: "",
|
73
|
-
messages: [],
|
74
|
-
error: err instanceof Error ? err.message : "Failed to fetch thread details",
|
75
|
-
};
|
76
|
-
}
|
77
|
-
})));
|
78
|
-
allThreads.push(...results);
|
79
|
-
fetched = allThreads.length;
|
80
|
-
if (!nextPageToken || allThreads.length >= max)
|
81
|
-
break;
|
82
|
-
pageToken = nextPageToken;
|
83
|
-
}
|
84
|
-
return {
|
85
|
-
success: errorMessages.length === 0,
|
86
|
-
threads: allThreads,
|
87
|
-
error: errorMessages.join("; "),
|
88
|
-
};
|
89
|
-
}
|
90
|
-
catch (error) {
|
91
|
-
return {
|
92
|
-
success: false,
|
93
|
-
error: error instanceof Error ? error.message : "Unknown error listing Gmail threads",
|
94
|
-
threads: [],
|
95
|
-
};
|
96
|
-
}
|
97
|
-
});
|
98
|
-
exports.default = listGmailThreads;
|
@@ -1,91 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
-
const missingAuthConstants_1 = require("../../util/missingAuthConstants");
|
14
|
-
const decodeMessage_1 = require("./utils/decodeMessage");
|
15
|
-
const searchGmailMessages = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
16
|
-
if (!authParams.authToken) {
|
17
|
-
return { success: false, error: missingAuthConstants_1.MISSING_AUTH_TOKEN, messages: [] };
|
18
|
-
}
|
19
|
-
const { query, maxResults } = params;
|
20
|
-
const allMessages = [];
|
21
|
-
const max = maxResults !== null && maxResults !== void 0 ? maxResults : 100;
|
22
|
-
const errorMessages = [];
|
23
|
-
let pageToken = undefined;
|
24
|
-
let fetched = 0;
|
25
|
-
try {
|
26
|
-
while (fetched < max) {
|
27
|
-
const url = `https://gmail.googleapis.com/gmail/v1/users/me/messages?q=${encodeURIComponent(query)}` +
|
28
|
-
(pageToken ? `&pageToken=${encodeURIComponent(pageToken)}` : "") +
|
29
|
-
`&maxResults=${Math.min(100, max - fetched)}`;
|
30
|
-
const listRes = yield axiosClient_1.axiosClient.get(url, {
|
31
|
-
headers: {
|
32
|
-
Authorization: `Bearer ${authParams.authToken}`,
|
33
|
-
},
|
34
|
-
});
|
35
|
-
const { messages: messageList = [], nextPageToken } = listRes.data;
|
36
|
-
if (!Array.isArray(messageList) || messageList.length === 0)
|
37
|
-
break;
|
38
|
-
const remaining = max - allMessages.length;
|
39
|
-
const batch = messageList.slice(0, remaining);
|
40
|
-
const results = yield Promise.all(batch.map((msg) => __awaiter(void 0, void 0, void 0, function* () {
|
41
|
-
try {
|
42
|
-
const msgRes = yield axiosClient_1.axiosClient.get(`https://gmail.googleapis.com/gmail/v1/users/me/messages/${msg.id}?format=full`, {
|
43
|
-
headers: {
|
44
|
-
Authorization: `Bearer ${authParams.authToken}`,
|
45
|
-
},
|
46
|
-
});
|
47
|
-
const { id, threadId, snippet, labelIds, internalDate } = msgRes.data;
|
48
|
-
const emailBody = (0, decodeMessage_1.getEmailContent)(msgRes.data) || "";
|
49
|
-
return {
|
50
|
-
id,
|
51
|
-
threadId,
|
52
|
-
snippet,
|
53
|
-
labelIds,
|
54
|
-
internalDate,
|
55
|
-
emailBody,
|
56
|
-
};
|
57
|
-
}
|
58
|
-
catch (err) {
|
59
|
-
errorMessages.push(err instanceof Error ? err.message : "Failed to fetch message details");
|
60
|
-
return {
|
61
|
-
id: msg.id,
|
62
|
-
threadId: "",
|
63
|
-
snippet: "",
|
64
|
-
labelIds: [],
|
65
|
-
internalDate: "",
|
66
|
-
payload: {},
|
67
|
-
error: err instanceof Error ? err.message : "Failed to fetch message details",
|
68
|
-
};
|
69
|
-
}
|
70
|
-
})));
|
71
|
-
allMessages.push(...results);
|
72
|
-
fetched = allMessages.length;
|
73
|
-
if (!nextPageToken || allMessages.length >= max)
|
74
|
-
break;
|
75
|
-
pageToken = nextPageToken;
|
76
|
-
}
|
77
|
-
return {
|
78
|
-
success: errorMessages.length === 0,
|
79
|
-
messages: allMessages,
|
80
|
-
error: errorMessages.join("; "),
|
81
|
-
};
|
82
|
-
}
|
83
|
-
catch (error) {
|
84
|
-
return {
|
85
|
-
success: false,
|
86
|
-
error: error instanceof Error ? error.message : "Unknown error searching Gmail",
|
87
|
-
messages: [],
|
88
|
-
};
|
89
|
-
}
|
90
|
-
});
|
91
|
-
exports.default = searchGmailMessages;
|
@@ -1,45 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
-
const getComputerInventory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
14
|
-
const { authToken, baseUrl } = authParams;
|
15
|
-
const { section } = params;
|
16
|
-
if (!baseUrl) {
|
17
|
-
throw new Error("Base URL is required to fetch computer inventory");
|
18
|
-
}
|
19
|
-
const apiUrl = `${baseUrl}/v1/computer-inventory`;
|
20
|
-
const queryParams = {};
|
21
|
-
if (section) {
|
22
|
-
queryParams.section = section;
|
23
|
-
}
|
24
|
-
try {
|
25
|
-
const response = yield axiosClient_1.axiosClient.get(apiUrl, {
|
26
|
-
headers: {
|
27
|
-
Authorization: `Bearer ${authToken}`,
|
28
|
-
Accept: "application/json",
|
29
|
-
},
|
30
|
-
params: queryParams,
|
31
|
-
});
|
32
|
-
return {
|
33
|
-
success: true,
|
34
|
-
data: response.data,
|
35
|
-
};
|
36
|
-
}
|
37
|
-
catch (error) {
|
38
|
-
console.error("Error retrieving computer inventory: ", error);
|
39
|
-
return {
|
40
|
-
success: false,
|
41
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
42
|
-
};
|
43
|
-
}
|
44
|
-
});
|
45
|
-
exports.default = getComputerInventory;
|
@@ -1,40 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
-
const getFileVaultRecoveryKey = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
14
|
-
const { authToken, baseUrl } = authParams;
|
15
|
-
const { computerId } = params;
|
16
|
-
if (!baseUrl || !computerId) {
|
17
|
-
throw new Error("Base URL and Computer ID are required to fetch FileVault2 recovery key");
|
18
|
-
}
|
19
|
-
const apiUrl = `${baseUrl}/JSSResource/computers/${computerId}/FileVault2RecoveryKey`;
|
20
|
-
try {
|
21
|
-
const response = yield axiosClient_1.axiosClient.get(apiUrl, {
|
22
|
-
headers: {
|
23
|
-
Authorization: `Bearer ${authToken}`,
|
24
|
-
Accept: "application/json",
|
25
|
-
},
|
26
|
-
});
|
27
|
-
return {
|
28
|
-
success: true,
|
29
|
-
data: response.data,
|
30
|
-
};
|
31
|
-
}
|
32
|
-
catch (error) {
|
33
|
-
console.error("Error retrieving FileVault2 recovery key: ", error);
|
34
|
-
return {
|
35
|
-
success: false,
|
36
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
37
|
-
};
|
38
|
-
}
|
39
|
-
});
|
40
|
-
exports.default = getFileVaultRecoveryKey;
|
@@ -1,37 +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 restartJamfComputerById = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
12
|
-
const { authToken, subdomain } = authParams;
|
13
|
-
const { computerId } = 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}/api/command/v1/computers/${computerId}/restart`, {
|
20
|
-
headers: {
|
21
|
-
Authorization: `Bearer ${authToken}`,
|
22
|
-
Accept: "application/json",
|
23
|
-
},
|
24
|
-
});
|
25
|
-
return {
|
26
|
-
success: true,
|
27
|
-
};
|
28
|
-
}
|
29
|
-
catch (error) {
|
30
|
-
console.error("Error restarting Jamf computer: ", error);
|
31
|
-
return {
|
32
|
-
success: false,
|
33
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
34
|
-
};
|
35
|
-
}
|
36
|
-
});
|
37
|
-
export default restartJamfComputerById;
|