@credal/actions 0.2.52 → 0.2.54

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.
@@ -87,7 +87,15 @@ const searchRepository = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pa
87
87
  });
88
88
  const prItems = issueResults.data.items.filter(item => item.pull_request).slice(0, MAX_ISSUES_OR_PRS);
89
89
  const prNumbers = prItems.map(item => item.number);
90
- const prFiles = yield Promise.all(prNumbers.map(number => octokit.rest.pulls.listFiles({ owner: organization, repo: repository, pull_number: number })));
90
+ const prFiles = yield Promise.all(prNumbers.map((number) => __awaiter(void 0, void 0, void 0, function* () {
91
+ try {
92
+ return yield octokit.rest.pulls.listFiles({ owner: organization, repo: repository, pull_number: number });
93
+ }
94
+ catch (error) {
95
+ console.error(`Error fetching PR files for PR ${number}:`, error);
96
+ return { data: [] };
97
+ }
98
+ })));
91
99
  const issuesAndPRs = issueResults.data.items
92
100
  .slice(0, MAX_ISSUES_OR_PRS)
93
101
  .map(item => {
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { createAxiosClientWithTimeout } from "../../util/axiosClient.js";
10
+ import { createAxiosClientWithTimeout, isAxiosTimeoutError } from "../../util/axiosClient.js";
11
11
  import mammoth from "mammoth";
12
12
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
13
13
  import { extractTextFromPdf } from "../../../utils/pdf.js";
@@ -50,16 +50,21 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
50
50
  content = parseGoogleDocFromRawContentToPlainText(docsRes.data);
51
51
  }
52
52
  catch (docsError) {
53
- console.log("Error using Google Docs API", docsError);
54
- // Fallback to Drive API export if Docs API fails
55
- const exportUrl = `${BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
56
- const exportRes = yield axiosClient.get(exportUrl, {
57
- headers: {
58
- Authorization: `Bearer ${authParams.authToken}`,
59
- },
60
- responseType: "text",
61
- });
62
- content = exportRes.data;
53
+ if (isAxiosTimeoutError(docsError)) {
54
+ console.log("Request timed out using Google Docs API - dont retry");
55
+ }
56
+ else {
57
+ console.log("Error using Google Docs API", docsError);
58
+ // Fallback to Drive API export if Docs API fails
59
+ const exportUrl = `${BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
60
+ const exportRes = yield axiosClient.get(exportUrl, {
61
+ headers: {
62
+ Authorization: `Bearer ${authParams.authToken}`,
63
+ },
64
+ responseType: "text",
65
+ });
66
+ content = exportRes.data;
67
+ }
63
68
  }
64
69
  }
65
70
  // Google Sheets - use Google Sheets API instead of Drive export
@@ -74,17 +79,22 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
74
79
  content = parseGoogleSheetsFromRawContentToPlainText(sheetsRes.data);
75
80
  }
76
81
  catch (sheetsError) {
77
- console.log("Error using Google Sheets API", sheetsError);
78
- const exportUrl = `${BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/csv${sharedDriveParams}`;
79
- const exportRes = yield axiosClient.get(exportUrl, {
80
- headers: { Authorization: `Bearer ${authParams.authToken}` },
81
- responseType: "text",
82
- });
83
- content = exportRes.data
84
- .split("\n")
85
- .map((line) => line.replace(/,+$/, ""))
86
- .map((line) => line.replace(/,{2,}/g, ","))
87
- .join("\n");
82
+ if (isAxiosTimeoutError(sheetsError)) {
83
+ console.log("Request timed out using Google Sheets API - dont retry");
84
+ }
85
+ else {
86
+ console.log("Error fetching file", sheetsError);
87
+ const exportUrl = `${BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/csv${sharedDriveParams}`;
88
+ const exportRes = yield axiosClient.get(exportUrl, {
89
+ headers: { Authorization: `Bearer ${authParams.authToken}` },
90
+ responseType: "text",
91
+ });
92
+ content = exportRes.data
93
+ .split("\n")
94
+ .map((line) => line.replace(/,+$/, ""))
95
+ .map((line) => line.replace(/,{2,}/g, ","))
96
+ .join("\n");
97
+ }
88
98
  }
89
99
  }
90
100
  // Google Slides - use Google Slides API instead of Drive export
@@ -99,13 +109,18 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
99
109
  content = parseGoogleSlidesFromRawContentToPlainText(slidesRes.data);
100
110
  }
101
111
  catch (slidesError) {
102
- console.log("Error using Google Slides API", slidesError);
103
- const exportUrl = `${BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
104
- const exportRes = yield axiosClient.get(exportUrl, {
105
- headers: { Authorization: `Bearer ${authParams.authToken}` },
106
- responseType: "text",
107
- });
108
- content = exportRes.data;
112
+ if (isAxiosTimeoutError(slidesError)) {
113
+ console.log("Request timed out using Google Slides API - dont retry");
114
+ }
115
+ else {
116
+ console.log("Error using Google Slides API", slidesError);
117
+ const exportUrl = `${BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
118
+ const exportRes = yield axiosClient.get(exportUrl, {
119
+ headers: { Authorization: `Bearer ${authParams.authToken}` },
120
+ responseType: "text",
121
+ });
122
+ content = exportRes.data;
123
+ }
109
124
  }
110
125
  }
111
126
  // PDF files - download and extract text using pdfjs-dist
@@ -4,5 +4,6 @@ export declare class ApiError extends Error {
4
4
  data?: any;
5
5
  constructor(message: string, status?: number, data?: any);
6
6
  }
7
+ export declare function isAxiosTimeoutError(error: unknown): boolean;
7
8
  export declare const axiosClient: AxiosInstance;
8
9
  export declare function createAxiosClientWithTimeout(timeout: number): AxiosInstance;
@@ -7,6 +7,9 @@ export class ApiError extends Error {
7
7
  this.data = data;
8
8
  }
9
9
  }
10
+ export function isAxiosTimeoutError(error) {
11
+ return error instanceof ApiError && !error.status && !error.data;
12
+ }
10
13
  /** Create a configured axios instance with interceptors */
11
14
  function createAxiosClient(timeout) {
12
15
  const instance = axios.create({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.52",
3
+ "version": "0.2.54",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,