@credal/actions 0.2.40 → 0.2.42

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.
@@ -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: ["pageId", "title", "content"],
743
+ required: ["success"],
730
744
  properties: {
731
- pageId: {
732
- type: "string",
733
- description: "The ID of the page",
745
+ success: {
746
+ type: "boolean",
747
+ description: "Whether the page content was successfully retrieved",
734
748
  },
735
- title: {
749
+ error: {
736
750
  type: "string",
737
- description: "The title of the page",
751
+ description: "The error that occurred if the page content was not successfully retrieved",
738
752
  },
739
- content: {
740
- type: "string",
741
- description: "The content of the page in storage format (HTML)",
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.ZodVoid;
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
- pageId: z.ZodString;
853
- title: z.ZodString;
854
- content: z.ZodString;
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
- pageId: string;
857
- title: string;
858
- content: string;
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
- pageId: string;
861
- title: string;
862
- content: string;
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.void();
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
- pageId: z.string().describe("The ID of the page"),
263
- title: z.string().describe("The title of the page"),
264
- content: z.string().describe("The content of the page in storage format (HTML)"),
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"),
@@ -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: string[];
12
- properties: Record<string, any>;
12
+ required?: string[] | undefined;
13
+ properties?: Record<string, any> | undefined;
14
+ oneOf?: any[] | undefined;
13
15
  }, {
14
16
  type: string;
15
- required: string[];
16
- properties: Record<string, any>;
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: string[];
25
- properties: Record<string, any>;
28
+ required?: string[] | undefined;
29
+ properties?: Record<string, any> | undefined;
30
+ oneOf?: any[] | undefined;
26
31
  }, {
27
32
  type: string;
28
- required: string[];
29
- properties: Record<string, any>;
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: string[];
42
- properties: Record<string, any>;
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: string[];
47
- properties: Record<string, any>;
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: string[];
57
- properties: Record<string, any>;
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: string[];
62
- properties: Record<string, any>;
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>;
@@ -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
- // check required fields
72
- const requiredFields = object.required;
73
- for (const field of requiredFields) {
74
- if (!object.properties[field]) {
75
- throw new Error(`Required field ${field} is missing`);
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
- const cloudDetails = yield axiosClient.get("https://api.atlassian.com/oauth/token/accessible-resources", {
21
- headers: {
22
- Authorization: `Bearer ${authToken}`,
23
- },
24
- });
25
- const cloudId = cloudDetails.data[0].id;
26
- const baseUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/api/v2`;
27
- const config = getConfluenceRequestConfig(baseUrl, authToken);
28
- // Get page content and metadata
29
- const response = yield axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
30
- // Extract needed data from response
31
- const title = response.data.title;
32
- const content = ((_c = (_b = response.data.body) === null || _b === void 0 ? void 0 : _b.storage) === null || _c === void 0 ? void 0 : _c.value) || "";
33
- return {
34
- pageId,
35
- title,
36
- content,
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
- const config = getConfluenceRequestConfig(baseUrl, authToken);
27
- // Get current page content and version number
28
- const response = yield axiosClient.get(`/pages/${pageId}?body-format=storage`, config);
29
- const currVersion = response.data.version.number;
30
- const payload = {
31
- id: pageId,
32
- status: "current",
33
- title,
34
- body: {
35
- representation: "storage",
36
- value: content,
37
- },
38
- version: {
39
- number: currVersion + 1,
40
- },
41
- };
42
- yield axiosClient.put(`/pages/${pageId}`, payload, config);
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;
@@ -16,14 +16,14 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
16
16
  }
17
17
  const { fileId, limit } = params;
18
18
  try {
19
- // First, get file metadata to determine the file type
20
- const metadataUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?fields=name,mimeType,size`;
19
+ // First, get file metadata to determine the file type and if it's in a shared drive
20
+ const metadataUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?fields=name,mimeType,size,driveId,parents&supportsAllDrives=true`;
21
21
  const metadataRes = yield axiosClient.get(metadataUrl, {
22
22
  headers: {
23
23
  Authorization: `Bearer ${authParams.authToken}`,
24
24
  },
25
25
  });
26
- const { name: fileName, mimeType, size } = metadataRes.data;
26
+ const { name: fileName, mimeType, size, driveId } = metadataRes.data;
27
27
  // Check if file is too large (50MB limit for safety)
28
28
  const maxFileSize = 50 * 1024 * 1024;
29
29
  if (size && parseInt(size) > maxFileSize) {
@@ -33,10 +33,12 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
33
33
  };
34
34
  }
35
35
  let content = "";
36
+ // Create shared drive parameters if the file is in a shared drive
37
+ const sharedDriveParams = driveId ? "&supportsAllDrives=true" : "";
36
38
  // Handle different file types - read content directly
37
39
  if (mimeType === "application/vnd.google-apps.document") {
38
40
  // Google Docs - download as plain text
39
- const exportUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}/export?mimeType=text/plain`;
41
+ const exportUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
40
42
  const exportRes = yield axiosClient.get(exportUrl, {
41
43
  headers: {
42
44
  Authorization: `Bearer ${authParams.authToken}`,
@@ -47,7 +49,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
47
49
  }
48
50
  else if (mimeType === "application/vnd.google-apps.spreadsheet") {
49
51
  // Google Sheets - download as CSV
50
- const exportUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}/export?mimeType=text/csv`;
52
+ const exportUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}/export?mimeType=text/csv${sharedDriveParams}`;
51
53
  const exportRes = yield axiosClient.get(exportUrl, {
52
54
  headers: {
53
55
  Authorization: `Bearer ${authParams.authToken}`,
@@ -63,7 +65,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
63
65
  }
64
66
  else if (mimeType === "application/vnd.google-apps.presentation") {
65
67
  // Google Slides - download as plain text
66
- const exportUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}/export?mimeType=text/plain`;
68
+ const exportUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
67
69
  const exportRes = yield axiosClient.get(exportUrl, {
68
70
  headers: {
69
71
  Authorization: `Bearer ${authParams.authToken}`,
@@ -81,7 +83,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
81
83
  else if (mimeType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
82
84
  mimeType === "application/msword") {
83
85
  // Word documents (.docx or .doc) - download and extract text using mammoth
84
- const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
86
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media${sharedDriveParams}`;
85
87
  const downloadRes = yield axiosClient.get(downloadUrl, {
86
88
  headers: {
87
89
  Authorization: `Bearer ${authParams.authToken}`,
@@ -105,7 +107,7 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
105
107
  mimeType === "application/rtf" ||
106
108
  (mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith("text/"))) {
107
109
  // Text-based files
108
- const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
110
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media${sharedDriveParams}`;
109
111
  const downloadRes = yield axiosClient.get(downloadUrl, {
110
112
  headers: {
111
113
  Authorization: `Bearer ${authParams.authToken}`,
@@ -0,0 +1,3 @@
1
+ import type { googleOauthSearchDriveAndGetContentByQueryFunction } from "../../autogen/types.js";
2
+ declare const searchDriveAndGetContentByQuery: googleOauthSearchDriveAndGetContentByQueryFunction;
3
+ export default searchDriveAndGetContentByQuery;
@@ -0,0 +1,78 @@
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
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
12
+ import extractContentFromDriveFileId from "./utils/extractContentFromDriveFileId.js";
13
+ const searchDriveAndGetContentByQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
14
+ var _b;
15
+ if (!authParams.authToken) {
16
+ return { success: false, error: MISSING_AUTH_TOKEN, files: [] };
17
+ }
18
+ const { query, fileLimit, fileSizeLimit } = params;
19
+ let files = [];
20
+ // 1. Search for files and get their metadata
21
+ const url = `https://www.googleapis.com/drive/v3/files?q=${encodeURIComponent(query)}&fields=files(id,name,mimeType,webViewLink)&supportsAllDrives=true&includeItemsFromAllDrives=true&corpora=allDrives`;
22
+ try {
23
+ const res = yield axiosClient.get(url, {
24
+ headers: {
25
+ Authorization: `Bearer ${authParams.authToken}`,
26
+ },
27
+ });
28
+ files =
29
+ ((_b = res.data.files) === null || _b === void 0 ? void 0 : _b.map((file) => ({
30
+ id: file.id,
31
+ name: file.name,
32
+ mimeType: file.mimeType,
33
+ url: file.webViewLink,
34
+ }))) || [];
35
+ }
36
+ catch (error) {
37
+ console.error("Error searching Google Drive", error);
38
+ return {
39
+ success: false,
40
+ error: error instanceof Error ? error.message : "Unknown error",
41
+ files: [],
42
+ };
43
+ }
44
+ files = fileLimit ? files.splice(0, fileLimit) : files;
45
+ // 2. Extract content from files and do some smart range selection
46
+ const processedFiles = yield Promise.all(files
47
+ .filter((file) => file.id && file.mimeType)
48
+ .map((file) => __awaiter(void 0, void 0, void 0, function* () {
49
+ const content = yield extractContentFromDriveFileId({
50
+ params: { fileId: file.id, mimeType: file.mimeType },
51
+ authParams,
52
+ });
53
+ if (content.success) {
54
+ let selectedContent = content.content;
55
+ if (fileSizeLimit && selectedContent && selectedContent.length > fileSizeLimit) {
56
+ selectedContent = selectedContent.substring(0, fileSizeLimit);
57
+ }
58
+ return {
59
+ id: file.id || "",
60
+ name: file.name || "",
61
+ mimeType: file.mimeType || "",
62
+ url: file.url || "",
63
+ content: selectedContent,
64
+ };
65
+ }
66
+ else {
67
+ return {
68
+ id: file.id || "",
69
+ name: file.name || "",
70
+ mimeType: file.mimeType || "",
71
+ url: file.url || "",
72
+ error: content.error,
73
+ };
74
+ }
75
+ })));
76
+ return { success: true, files: processedFiles };
77
+ });
78
+ export default searchDriveAndGetContentByQuery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,