@credal/actions 0.2.32 → 0.2.34
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 +19 -1
- package/dist/actions/autogen/templates.d.ts +5 -0
- package/dist/actions/autogen/templates.js +377 -0
- package/dist/actions/autogen/types.d.ts +370 -0
- package/dist/actions/autogen/types.js +122 -0
- package/dist/actions/groups.js +3 -1
- package/dist/actions/providers/jira/createServiceDeskRequest.d.ts +3 -0
- package/dist/actions/providers/jira/createServiceDeskRequest.js +54 -0
- package/dist/actions/providers/jira/getServiceDesks.d.ts +3 -0
- package/dist/actions/providers/jira/getServiceDesks.js +101 -0
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +3 -0
- package/dist/actions/providers/{jamf/getComputerInventory.js → salesforce/getSalesforceRecordByQuery.js} +14 -16
- package/dist/actions/providers/salesforce/searchSalesforceRecords.d.ts +3 -0
- package/dist/actions/providers/salesforce/searchSalesforceRecords.js +52 -0
- package/package.json +1 -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/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
- package/dist/actions/providers/jamf/types.d.ts +0 -8
- package/dist/actions/providers/jamf/types.js +0 -7
@@ -0,0 +1,101 @@
|
|
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 getServiceDesks = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
|
12
|
+
const { authToken, cloudId } = authParams;
|
13
|
+
if (!cloudId || !authToken) {
|
14
|
+
throw new Error("Valid Cloud ID and auth token are required to get service desks");
|
15
|
+
}
|
16
|
+
const baseUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/servicedeskapi/servicedesk`;
|
17
|
+
try {
|
18
|
+
const allServiceDesks = [];
|
19
|
+
let start = 0;
|
20
|
+
const limit = 50; // Set a reasonable limit per request
|
21
|
+
let isLastPage = false;
|
22
|
+
// Keep fetching pages until we reach the last page
|
23
|
+
while (!isLastPage) {
|
24
|
+
const apiUrl = `${baseUrl}?start=${start}&limit=${limit}`;
|
25
|
+
const response = yield axiosClient.get(apiUrl, {
|
26
|
+
headers: {
|
27
|
+
Authorization: `Bearer ${authToken}`,
|
28
|
+
Accept: "application/json",
|
29
|
+
},
|
30
|
+
});
|
31
|
+
const { values, isLastPage: lastPage, size } = response.data;
|
32
|
+
const serviceDesks = [];
|
33
|
+
for (const serviceDesk of values) {
|
34
|
+
// Get request types
|
35
|
+
const { requestTypes } = yield getServiceDeskRequestTypes({
|
36
|
+
authParams,
|
37
|
+
serviceDeskId: serviceDesk.id,
|
38
|
+
});
|
39
|
+
serviceDesks.push(Object.assign(Object.assign({}, serviceDesk), { requestTypes }));
|
40
|
+
}
|
41
|
+
// Add current page's service desks to our collection
|
42
|
+
allServiceDesks.push(...serviceDesks);
|
43
|
+
// Update pagination variables
|
44
|
+
isLastPage = lastPage;
|
45
|
+
start += size; // Move to next page
|
46
|
+
}
|
47
|
+
return {
|
48
|
+
success: true,
|
49
|
+
serviceDesks: allServiceDesks,
|
50
|
+
};
|
51
|
+
}
|
52
|
+
catch (error) {
|
53
|
+
console.error("Error retrieving service desks: ", error);
|
54
|
+
return {
|
55
|
+
success: false,
|
56
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
57
|
+
};
|
58
|
+
}
|
59
|
+
});
|
60
|
+
function getServiceDeskRequestTypes(args) {
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
62
|
+
const { authParams, serviceDeskId } = args;
|
63
|
+
const { authToken, cloudId } = authParams;
|
64
|
+
if (!cloudId || !authToken) {
|
65
|
+
throw new Error("Valid Cloud ID and auth token are required to get service desks");
|
66
|
+
}
|
67
|
+
const baseUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/servicedeskapi/servicedesk/${serviceDeskId}/requesttype`;
|
68
|
+
try {
|
69
|
+
const allRequestTypes = [];
|
70
|
+
let start = 0;
|
71
|
+
const limit = 50; // Set a reasonable limit per request
|
72
|
+
let isLastPage = false;
|
73
|
+
// Keep fetching pages until we reach the last page
|
74
|
+
while (!isLastPage) {
|
75
|
+
const apiUrl = `${baseUrl}?start=${start}&limit=${limit}`;
|
76
|
+
const response = yield axiosClient.get(apiUrl, {
|
77
|
+
headers: {
|
78
|
+
Authorization: `Bearer ${authToken}`,
|
79
|
+
Accept: "application/json",
|
80
|
+
},
|
81
|
+
});
|
82
|
+
const { values, isLastPage: lastPage, size } = response.data;
|
83
|
+
// Add current page's service desks to our collection
|
84
|
+
allRequestTypes.push(...values);
|
85
|
+
// Update pagination variables
|
86
|
+
isLastPage = lastPage;
|
87
|
+
start += size; // Move to next page
|
88
|
+
}
|
89
|
+
return {
|
90
|
+
requestTypes: allRequestTypes,
|
91
|
+
};
|
92
|
+
}
|
93
|
+
catch (error) {
|
94
|
+
console.error("Error retrieving service desks: ", error);
|
95
|
+
return {
|
96
|
+
requestTypes: [],
|
97
|
+
};
|
98
|
+
}
|
99
|
+
});
|
100
|
+
}
|
101
|
+
export default getServiceDesks;
|
@@ -10,36 +10,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
const axiosClient_1 = require("../../util/axiosClient");
|
13
|
-
const
|
13
|
+
const getSalesforceRecordByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
14
14
|
const { authToken, baseUrl } = authParams;
|
15
|
-
const {
|
16
|
-
if (!baseUrl) {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
if (section) {
|
22
|
-
queryParams.section = section;
|
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
|
+
};
|
23
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
24
|
try {
|
25
|
-
const response = yield axiosClient_1.axiosClient.get(
|
25
|
+
const response = yield axiosClient_1.axiosClient.get(url, {
|
26
26
|
headers: {
|
27
27
|
Authorization: `Bearer ${authToken}`,
|
28
|
-
Accept: "application/json",
|
29
28
|
},
|
30
|
-
params: queryParams,
|
31
29
|
});
|
32
30
|
return {
|
33
31
|
success: true,
|
34
|
-
|
32
|
+
records: response.data,
|
35
33
|
};
|
36
34
|
}
|
37
35
|
catch (error) {
|
38
|
-
console.error("Error retrieving
|
36
|
+
console.error("Error retrieving Salesforce record:", error);
|
39
37
|
return {
|
40
38
|
success: false,
|
41
|
-
error: error instanceof Error ? error.message : "
|
39
|
+
error: error instanceof Error ? error.message : "An unknown error occurred",
|
42
40
|
};
|
43
41
|
}
|
44
42
|
});
|
45
|
-
exports.default =
|
43
|
+
exports.default = getSalesforceRecordByQuery;
|
@@ -0,0 +1,52 @@
|
|
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 { ApiError, axiosClient } from "../../util/axiosClient.js";
|
11
|
+
const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
12
|
+
const { authToken, baseUrl } = authParams;
|
13
|
+
const { keyword, recordType, fieldsToSearch } = params;
|
14
|
+
if (!authToken || !baseUrl) {
|
15
|
+
return {
|
16
|
+
success: false,
|
17
|
+
error: "authToken and baseUrl are required for Salesforce API",
|
18
|
+
};
|
19
|
+
}
|
20
|
+
const maxLimit = 25;
|
21
|
+
const url = `${baseUrl}/services/data/v64.0/search/?q=${encodeURIComponent(`FIND {${keyword}} RETURNING ${recordType} (${fieldsToSearch.join(", ")}) LIMIT ${params.limit && params.limit <= maxLimit ? params.limit : maxLimit}`)}`;
|
22
|
+
try {
|
23
|
+
const response = yield axiosClient.get(url, {
|
24
|
+
headers: {
|
25
|
+
Authorization: `Bearer ${authToken}`,
|
26
|
+
},
|
27
|
+
});
|
28
|
+
if (recordType === "Knowledge__kav") {
|
29
|
+
for (const record of response.data.searchRecords) {
|
30
|
+
if (record.Article_Body__c) {
|
31
|
+
record.Article_Body__c = record.Article_Body__c.replace(/<[^>]*>/g, "");
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return {
|
36
|
+
success: true,
|
37
|
+
searchRecords: response.data.searchRecords,
|
38
|
+
};
|
39
|
+
}
|
40
|
+
catch (error) {
|
41
|
+
console.error("Error retrieving Salesforce record:", error);
|
42
|
+
return {
|
43
|
+
success: false,
|
44
|
+
error: error instanceof ApiError
|
45
|
+
? error.data.length > 0
|
46
|
+
? error.data[0].message
|
47
|
+
: error.message
|
48
|
+
: "An unknown error occurred",
|
49
|
+
};
|
50
|
+
}
|
51
|
+
});
|
52
|
+
export default searchSalesforceRecords;
|
package/package.json
CHANGED
@@ -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,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;
|