@credal/actions 0.2.39 → 0.2.41
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 +36 -9
- package/dist/actions/autogen/types.d.ts +39 -10
- package/dist/actions/autogen/types.js +13 -4
- package/dist/actions/parse.d.ts +30 -20
- package/dist/actions/parse.js +19 -7
- package/dist/actions/providers/confluence/fetchPageContent.js +31 -18
- package/dist/actions/providers/confluence/overwritePage.js +28 -17
- package/dist/actions/providers/google-oauth/listGmailThreads.d.ts +3 -0
- package/dist/actions/providers/google-oauth/listGmailThreads.js +98 -0
- package/dist/actions/providers/google-oauth/searchDriveByKeywords.js +1 -1
- package/dist/actions/providers/google-oauth/searchDriveByQuery.js +1 -1
- package/dist/actions/providers/google-oauth/searchGmailMessages.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchGmailMessages.js +91 -0
- package/dist/actions/providers/jamf/getComputerInventory.d.ts +3 -0
- package/dist/actions/providers/{salesforce/getSalesforceRecordByQuery.js → jamf/getComputerInventory.js} +16 -14
- package/dist/actions/providers/jamf/getFileVaultRecoveryKey.d.ts +3 -0
- package/dist/actions/providers/jamf/getFileVaultRecoveryKey.js +40 -0
- package/dist/actions/providers/jamf/restartJamfComputerById.d.ts +3 -0
- package/dist/actions/providers/jamf/restartJamfComputerById.js +37 -0
- package/dist/actions/providers/jamf/types.d.ts +8 -0
- package/dist/actions/providers/jamf/types.js +7 -0
- package/dist/actions/providers/salesforce/searchSalesforceRecords.js +2 -1
- package/package.json +1 -1
- package/dist/actions/providers/salesforce/getSalesforceRecordByQuery.d.ts +0 -3
@@ -708,6 +708,20 @@ export const confluenceOverwritePageDefinition = {
|
|
708
708
|
},
|
709
709
|
},
|
710
710
|
},
|
711
|
+
output: {
|
712
|
+
type: "object",
|
713
|
+
required: ["success"],
|
714
|
+
properties: {
|
715
|
+
success: {
|
716
|
+
type: "boolean",
|
717
|
+
description: "Whether the page was successfully updated",
|
718
|
+
},
|
719
|
+
error: {
|
720
|
+
type: "string",
|
721
|
+
description: "The error that occurred if the page was not successfully updated",
|
722
|
+
},
|
723
|
+
},
|
724
|
+
},
|
711
725
|
name: "overwritePage",
|
712
726
|
provider: "confluence",
|
713
727
|
};
|
@@ -726,19 +740,32 @@ export const confluenceFetchPageContentDefinition = {
|
|
726
740
|
},
|
727
741
|
output: {
|
728
742
|
type: "object",
|
729
|
-
required: ["
|
743
|
+
required: ["success"],
|
730
744
|
properties: {
|
731
|
-
|
732
|
-
type: "
|
733
|
-
description: "
|
745
|
+
success: {
|
746
|
+
type: "boolean",
|
747
|
+
description: "Whether the page content was successfully retrieved",
|
734
748
|
},
|
735
|
-
|
749
|
+
error: {
|
736
750
|
type: "string",
|
737
|
-
description: "The
|
751
|
+
description: "The error that occurred if the page content was not successfully retrieved",
|
738
752
|
},
|
739
|
-
|
740
|
-
type: "
|
741
|
-
|
753
|
+
data: {
|
754
|
+
type: "object",
|
755
|
+
properties: {
|
756
|
+
pageId: {
|
757
|
+
type: "string",
|
758
|
+
description: "The ID of the page",
|
759
|
+
},
|
760
|
+
title: {
|
761
|
+
type: "string",
|
762
|
+
description: "The title of the page",
|
763
|
+
},
|
764
|
+
content: {
|
765
|
+
type: "string",
|
766
|
+
description: "The content of the page in storage format (HTML)",
|
767
|
+
},
|
768
|
+
},
|
742
769
|
},
|
743
770
|
},
|
744
771
|
},
|
@@ -837,7 +837,16 @@ export declare const confluenceOverwritePageParamsSchema: z.ZodObject<{
|
|
837
837
|
content: string;
|
838
838
|
}>;
|
839
839
|
export type confluenceOverwritePageParamsType = z.infer<typeof confluenceOverwritePageParamsSchema>;
|
840
|
-
export declare const confluenceOverwritePageOutputSchema: z.
|
840
|
+
export declare const confluenceOverwritePageOutputSchema: z.ZodObject<{
|
841
|
+
success: z.ZodBoolean;
|
842
|
+
error: z.ZodOptional<z.ZodString>;
|
843
|
+
}, "strip", z.ZodTypeAny, {
|
844
|
+
success: boolean;
|
845
|
+
error?: string | undefined;
|
846
|
+
}, {
|
847
|
+
success: boolean;
|
848
|
+
error?: string | undefined;
|
849
|
+
}>;
|
841
850
|
export type confluenceOverwritePageOutputType = z.infer<typeof confluenceOverwritePageOutputSchema>;
|
842
851
|
export type confluenceOverwritePageFunction = ActionFunction<confluenceOverwritePageParamsType, AuthParamsType, confluenceOverwritePageOutputType>;
|
843
852
|
export declare const confluenceFetchPageContentParamsSchema: z.ZodObject<{
|
@@ -849,17 +858,37 @@ export declare const confluenceFetchPageContentParamsSchema: z.ZodObject<{
|
|
849
858
|
}>;
|
850
859
|
export type confluenceFetchPageContentParamsType = z.infer<typeof confluenceFetchPageContentParamsSchema>;
|
851
860
|
export declare const confluenceFetchPageContentOutputSchema: z.ZodObject<{
|
852
|
-
|
853
|
-
|
854
|
-
|
861
|
+
success: z.ZodBoolean;
|
862
|
+
error: z.ZodOptional<z.ZodString>;
|
863
|
+
data: z.ZodOptional<z.ZodObject<{
|
864
|
+
pageId: z.ZodOptional<z.ZodString>;
|
865
|
+
title: z.ZodOptional<z.ZodString>;
|
866
|
+
content: z.ZodOptional<z.ZodString>;
|
867
|
+
}, "strip", z.ZodTypeAny, {
|
868
|
+
pageId?: string | undefined;
|
869
|
+
title?: string | undefined;
|
870
|
+
content?: string | undefined;
|
871
|
+
}, {
|
872
|
+
pageId?: string | undefined;
|
873
|
+
title?: string | undefined;
|
874
|
+
content?: string | undefined;
|
875
|
+
}>>;
|
855
876
|
}, "strip", z.ZodTypeAny, {
|
856
|
-
|
857
|
-
|
858
|
-
|
877
|
+
success: boolean;
|
878
|
+
error?: string | undefined;
|
879
|
+
data?: {
|
880
|
+
pageId?: string | undefined;
|
881
|
+
title?: string | undefined;
|
882
|
+
content?: string | undefined;
|
883
|
+
} | undefined;
|
859
884
|
}, {
|
860
|
-
|
861
|
-
|
862
|
-
|
885
|
+
success: boolean;
|
886
|
+
error?: string | undefined;
|
887
|
+
data?: {
|
888
|
+
pageId?: string | undefined;
|
889
|
+
title?: string | undefined;
|
890
|
+
content?: string | undefined;
|
891
|
+
} | undefined;
|
863
892
|
}>;
|
864
893
|
export type confluenceFetchPageContentOutputType = z.infer<typeof confluenceFetchPageContentOutputSchema>;
|
865
894
|
export type confluenceFetchPageContentFunction = ActionFunction<confluenceFetchPageContentParamsType, AuthParamsType, confluenceFetchPageContentOutputType>;
|
@@ -254,14 +254,23 @@ export const confluenceOverwritePageParamsSchema = z.object({
|
|
254
254
|
title: z.string().describe("The title of the page that should be updated"),
|
255
255
|
content: z.string().describe("The new content for the page"),
|
256
256
|
});
|
257
|
-
export const confluenceOverwritePageOutputSchema = z.
|
257
|
+
export const confluenceOverwritePageOutputSchema = z.object({
|
258
|
+
success: z.boolean().describe("Whether the page was successfully updated"),
|
259
|
+
error: z.string().describe("The error that occurred if the page was not successfully updated").optional(),
|
260
|
+
});
|
258
261
|
export const confluenceFetchPageContentParamsSchema = z.object({
|
259
262
|
pageId: z.string().describe("The ID of the page to fetch content from"),
|
260
263
|
});
|
261
264
|
export const confluenceFetchPageContentOutputSchema = z.object({
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
+
success: z.boolean().describe("Whether the page content was successfully retrieved"),
|
266
|
+
error: z.string().describe("The error that occurred if the page content was not successfully retrieved").optional(),
|
267
|
+
data: z
|
268
|
+
.object({
|
269
|
+
pageId: z.string().describe("The ID of the page").optional(),
|
270
|
+
title: z.string().describe("The title of the page").optional(),
|
271
|
+
content: z.string().describe("The content of the page in storage format (HTML)").optional(),
|
272
|
+
})
|
273
|
+
.optional(),
|
265
274
|
});
|
266
275
|
export const jiraAssignJiraTicketParamsSchema = z.object({
|
267
276
|
projectKey: z.string().describe("The key for the project you want to add it to"),
|
package/dist/actions/parse.d.ts
CHANGED
@@ -4,29 +4,35 @@ declare const actionTemplateSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
4
4
|
scopes: z.ZodArray<z.ZodString, "many">;
|
5
5
|
parameters: z.ZodOptional<z.ZodObject<{
|
6
6
|
type: z.ZodString;
|
7
|
-
required: z.ZodArray<z.ZodString, "many"
|
8
|
-
properties: z.ZodRecord<z.ZodString, z.ZodAny
|
7
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
8
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
9
|
+
oneOf: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
9
10
|
}, "strip", z.ZodTypeAny, {
|
10
11
|
type: string;
|
11
|
-
required
|
12
|
-
properties
|
12
|
+
required?: string[] | undefined;
|
13
|
+
properties?: Record<string, any> | undefined;
|
14
|
+
oneOf?: any[] | undefined;
|
13
15
|
}, {
|
14
16
|
type: string;
|
15
|
-
required
|
16
|
-
properties
|
17
|
+
required?: string[] | undefined;
|
18
|
+
properties?: Record<string, any> | undefined;
|
19
|
+
oneOf?: any[] | undefined;
|
17
20
|
}>>;
|
18
21
|
output: z.ZodOptional<z.ZodObject<{
|
19
22
|
type: z.ZodString;
|
20
|
-
required: z.ZodArray<z.ZodString, "many"
|
21
|
-
properties: z.ZodRecord<z.ZodString, z.ZodAny
|
23
|
+
required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
24
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
25
|
+
oneOf: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
22
26
|
}, "strip", z.ZodTypeAny, {
|
23
27
|
type: string;
|
24
|
-
required
|
25
|
-
properties
|
28
|
+
required?: string[] | undefined;
|
29
|
+
properties?: Record<string, any> | undefined;
|
30
|
+
oneOf?: any[] | undefined;
|
26
31
|
}, {
|
27
32
|
type: string;
|
28
|
-
required
|
29
|
-
properties
|
33
|
+
required?: string[] | undefined;
|
34
|
+
properties?: Record<string, any> | undefined;
|
35
|
+
oneOf?: any[] | undefined;
|
30
36
|
}>>;
|
31
37
|
}, {
|
32
38
|
name: z.ZodString;
|
@@ -38,13 +44,15 @@ declare const actionTemplateSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
38
44
|
provider: string;
|
39
45
|
parameters?: {
|
40
46
|
type: string;
|
41
|
-
required
|
42
|
-
properties
|
47
|
+
required?: string[] | undefined;
|
48
|
+
properties?: Record<string, any> | undefined;
|
49
|
+
oneOf?: any[] | undefined;
|
43
50
|
} | undefined;
|
44
51
|
output?: {
|
45
52
|
type: string;
|
46
|
-
required
|
47
|
-
properties
|
53
|
+
required?: string[] | undefined;
|
54
|
+
properties?: Record<string, any> | undefined;
|
55
|
+
oneOf?: any[] | undefined;
|
48
56
|
} | undefined;
|
49
57
|
}, {
|
50
58
|
description: string;
|
@@ -53,13 +61,15 @@ declare const actionTemplateSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
53
61
|
provider: string;
|
54
62
|
parameters?: {
|
55
63
|
type: string;
|
56
|
-
required
|
57
|
-
properties
|
64
|
+
required?: string[] | undefined;
|
65
|
+
properties?: Record<string, any> | undefined;
|
66
|
+
oneOf?: any[] | undefined;
|
58
67
|
} | undefined;
|
59
68
|
output?: {
|
60
69
|
type: string;
|
61
|
-
required
|
62
|
-
properties
|
70
|
+
required?: string[] | undefined;
|
71
|
+
properties?: Record<string, any> | undefined;
|
72
|
+
oneOf?: any[] | undefined;
|
63
73
|
} | undefined;
|
64
74
|
}>;
|
65
75
|
export type ActionTemplate = z.infer<typeof actionTemplateSchema>;
|
package/dist/actions/parse.js
CHANGED
@@ -16,8 +16,9 @@ import { z } from "zod";
|
|
16
16
|
import { snakeToPascal } from "../utils/string.js";
|
17
17
|
const jsonObjectSchema = z.object({
|
18
18
|
type: z.string(),
|
19
|
-
required: z.array(z.string()),
|
20
|
-
properties: z.record(z.string(), z.any()), // Permissive for now, validate using JSON schema later
|
19
|
+
required: z.array(z.string()).optional(),
|
20
|
+
properties: z.record(z.string(), z.any()).optional(), // Permissive for now, validate using JSON schema later
|
21
|
+
oneOf: z.array(z.any()).optional(), // Support oneOf schemas
|
21
22
|
});
|
22
23
|
const actionSchema = z.object({
|
23
24
|
description: z.string(),
|
@@ -68,11 +69,22 @@ function validateObject(object) {
|
|
68
69
|
if (!validParameters) {
|
69
70
|
throw new Error(`Error validating object: ${JSON.stringify(ajv.errors, null, 4)}`);
|
70
71
|
}
|
71
|
-
//
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
// Handle oneOf schemas
|
73
|
+
if (object.oneOf) {
|
74
|
+
// For oneOf schemas, validate each option
|
75
|
+
for (const oneOfOption of object.oneOf) {
|
76
|
+
const validOption = ajv.validateSchema(oneOfOption);
|
77
|
+
if (!validOption) {
|
78
|
+
throw new Error(`Error validating oneOf option: ${JSON.stringify(ajv.errors, null, 4)}`);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
else if (object.required && object.properties) {
|
83
|
+
// Handle regular object schemas - check required fields
|
84
|
+
for (const field of object.required) {
|
85
|
+
if (!object.properties[field]) {
|
86
|
+
throw new Error(`Required field ${field} is missing`);
|
87
|
+
}
|
76
88
|
}
|
77
89
|
}
|
78
90
|
});
|
@@ -17,23 +17,36 @@ const confluenceFetchPageContent = (_a) => __awaiter(void 0, [_a], void 0, funct
|
|
17
17
|
if (!authToken) {
|
18
18
|
throw new Error(MISSING_AUTH_TOKEN);
|
19
19
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
20
|
+
try {
|
21
|
+
const cloudDetails = yield axiosClient.get("https://api.atlassian.com/oauth/token/accessible-resources", {
|
22
|
+
headers: {
|
23
|
+
Authorization: `Bearer ${authToken}`,
|
24
|
+
},
|
25
|
+
});
|
26
|
+
const cloudId = cloudDetails.data[0].id;
|
27
|
+
const baseUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/api/v2`;
|
28
|
+
const config = getConfluenceRequestConfig(baseUrl, authToken);
|
29
|
+
// Get page content and metadata
|
30
|
+
const response = yield axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
|
31
|
+
// Extract needed data from response
|
32
|
+
const title = response.data.title;
|
33
|
+
const content = ((_c = (_b = response.data.body) === null || _b === void 0 ? void 0 : _b.storage) === null || _c === void 0 ? void 0 : _c.value) || "";
|
34
|
+
return {
|
35
|
+
success: true,
|
36
|
+
data: {
|
37
|
+
pageId,
|
38
|
+
title,
|
39
|
+
content,
|
40
|
+
},
|
41
|
+
};
|
42
|
+
}
|
43
|
+
catch (error) {
|
44
|
+
return {
|
45
|
+
success: false,
|
46
|
+
error: error instanceof Error
|
47
|
+
? error.message
|
48
|
+
: "An unknown error occurred while fetching the Confluence page content.",
|
49
|
+
};
|
50
|
+
}
|
38
51
|
});
|
39
52
|
export default confluenceFetchPageContent;
|
@@ -23,22 +23,33 @@ const confluenceOverwritePage = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
23
23
|
});
|
24
24
|
const cloudId = cloudDetails.data[0].id;
|
25
25
|
const baseUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/api/v2`;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
try {
|
27
|
+
const config = getConfluenceRequestConfig(baseUrl, authToken);
|
28
|
+
// Get current page content and version number
|
29
|
+
const response = yield axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
|
30
|
+
const currVersion = response.data.version.number;
|
31
|
+
const payload = {
|
32
|
+
id: pageId,
|
33
|
+
status: "current",
|
34
|
+
title,
|
35
|
+
body: {
|
36
|
+
representation: "storage",
|
37
|
+
value: content,
|
38
|
+
},
|
39
|
+
version: {
|
40
|
+
number: currVersion + 1,
|
41
|
+
},
|
42
|
+
};
|
43
|
+
yield axiosClient.put(`/pages/${pageId}`, payload, config);
|
44
|
+
return {
|
45
|
+
success: true,
|
46
|
+
};
|
47
|
+
}
|
48
|
+
catch (error) {
|
49
|
+
return {
|
50
|
+
success: false,
|
51
|
+
error: error instanceof Error ? error.message : "An unknown error occurred while updating the Confluence page.",
|
52
|
+
};
|
53
|
+
}
|
43
54
|
});
|
44
55
|
export default confluenceOverwritePage;
|
@@ -0,0 +1,98 @@
|
|
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;
|
@@ -17,7 +17,7 @@ const searchDriveByKeywords = (_a) => __awaiter(void 0, [_a], void 0, function*
|
|
17
17
|
const { keywords, limit } = params;
|
18
18
|
// Build the query: fullText contains 'keyword1' or fullText contains 'keyword2' ...
|
19
19
|
const query = keywords.map(kw => `fullText contains '${kw.replace(/'/g, "\\'")}'`).join(" or ");
|
20
|
-
const url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true`;
|
20
|
+
const url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=allDrives`;
|
21
21
|
try {
|
22
22
|
const res = yield axiosClient.get(url, {
|
23
23
|
headers: {
|
@@ -15,7 +15,7 @@ const searchDriveByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
15
15
|
return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
|
16
16
|
}
|
17
17
|
const { query, limit } = params;
|
18
|
-
const url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true`;
|
18
|
+
const url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=allDrives`;
|
19
19
|
try {
|
20
20
|
const res = yield axiosClient.get(url, {
|
21
21
|
headers: {
|
@@ -0,0 +1,91 @@
|
|
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;
|
@@ -10,34 +10,36 @@ 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 getComputerInventory = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
14
14
|
const { authToken, baseUrl } = authParams;
|
15
|
-
const {
|
16
|
-
if (!
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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;
|
21
23
|
}
|
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(apiUrl, {
|
26
26
|
headers: {
|
27
27
|
Authorization: `Bearer ${authToken}`,
|
28
|
+
Accept: "application/json",
|
28
29
|
},
|
30
|
+
params: queryParams,
|
29
31
|
});
|
30
32
|
return {
|
31
33
|
success: true,
|
32
|
-
|
34
|
+
data: response.data,
|
33
35
|
};
|
34
36
|
}
|
35
37
|
catch (error) {
|
36
|
-
console.error("Error retrieving
|
38
|
+
console.error("Error retrieving computer inventory: ", error);
|
37
39
|
return {
|
38
40
|
success: false,
|
39
|
-
error: error instanceof Error ? error.message : "
|
41
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
40
42
|
};
|
41
43
|
}
|
42
44
|
});
|
43
|
-
exports.default =
|
45
|
+
exports.default = getComputerInventory;
|
@@ -0,0 +1,40 @@
|
|
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;
|
@@ -0,0 +1,37 @@
|
|
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;
|
@@ -18,7 +18,8 @@ const searchSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
18
18
|
};
|
19
19
|
}
|
20
20
|
const maxLimit = 25;
|
21
|
-
const
|
21
|
+
const dateFieldExists = fieldsToSearch.includes("CreatedDate");
|
22
|
+
const url = `${baseUrl}/services/data/v64.0/search/?q=${encodeURIComponent(`FIND {${keyword}} RETURNING ${recordType} (${fieldsToSearch.join(", ") + (dateFieldExists ? " ORDER BY CreatedDate DESC" : "")}) LIMIT ${params.limit && params.limit <= maxLimit ? params.limit : maxLimit}`)}`;
|
22
23
|
try {
|
23
24
|
const response = yield axiosClient.get(url, {
|
24
25
|
headers: {
|
package/package.json
CHANGED