@credal/actions 0.2.50 → 0.2.51

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.
@@ -9,8 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { axiosClient } from "../../util/axiosClient.js";
11
11
  import mammoth from "mammoth";
12
- import { google } from "googleapis";
13
- import { OAuth2Client } from "google-auth-library";
14
12
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
15
13
  import { extractTextFromPdf } from "../../../utils/pdf.js";
16
14
  import { parseGoogleDocFromRawContentToPlainText, parseGoogleSheetsFromRawContentToPlainText, parseGoogleSlidesFromRawContentToPlainText, } from "../../../utils/google.js";
@@ -39,15 +37,16 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
39
37
  }
40
38
  let content = "";
41
39
  const sharedDriveParams = driveId ? "&supportsAllDrives=true" : "";
42
- // Create OAuth2Client from the auth token
43
- const oauthClient = new OAuth2Client();
44
- oauthClient.setCredentials({ access_token: authParams.authToken });
45
40
  // Google Docs - use Google Docs API instead of Drive export
46
41
  if (mimeType === "application/vnd.google-apps.document") {
47
42
  try {
48
- const docs = google.docs({ auth: oauthClient, version: "v1" });
49
- const result = yield docs.documents.get({ documentId: fileId });
50
- content = parseGoogleDocFromRawContentToPlainText(result.data);
43
+ const docsUrl = `https://docs.googleapis.com/v1/documents/${fileId}`;
44
+ const docsRes = yield axiosClient.get(docsUrl, {
45
+ headers: {
46
+ Authorization: `Bearer ${authParams.authToken}`,
47
+ },
48
+ });
49
+ content = parseGoogleDocFromRawContentToPlainText(docsRes.data);
51
50
  }
52
51
  catch (docsError) {
53
52
  console.log("Error using Google Docs API", docsError);
@@ -65,15 +64,13 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
65
64
  // Google Sheets - use Google Sheets API instead of Drive export
66
65
  else if (mimeType === "application/vnd.google-apps.spreadsheet") {
67
66
  try {
68
- const sheets = google.sheets({
69
- auth: oauthClient,
70
- version: "v4",
71
- });
72
- const result = yield sheets.spreadsheets.get({
73
- spreadsheetId: fileId,
74
- includeGridData: true,
67
+ const sheetsUrl = `https://sheets.googleapis.com/v4/spreadsheets/${fileId}?includeGridData=true`;
68
+ const sheetsRes = yield axiosClient.get(sheetsUrl, {
69
+ headers: {
70
+ Authorization: `Bearer ${authParams.authToken}`,
71
+ },
75
72
  });
76
- content = parseGoogleSheetsFromRawContentToPlainText(result.data);
73
+ content = parseGoogleSheetsFromRawContentToPlainText(sheetsRes.data);
77
74
  }
78
75
  catch (sheetsError) {
79
76
  console.log("Error using Google Sheets API", sheetsError);
@@ -92,9 +89,13 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
92
89
  // Google Slides - use Google Slides API instead of Drive export
93
90
  else if (mimeType === "application/vnd.google-apps.presentation") {
94
91
  try {
95
- const slides = google.slides({ auth: oauthClient, version: "v1" });
96
- const result = yield slides.presentations.get({ presentationId: fileId });
97
- content = parseGoogleSlidesFromRawContentToPlainText(result.data);
92
+ const slidesUrl = `https://slides.googleapis.com/v1/presentations/${fileId}`;
93
+ const slidesRes = yield axiosClient.get(slidesUrl, {
94
+ headers: {
95
+ Authorization: `Bearer ${authParams.authToken}`,
96
+ },
97
+ });
98
+ content = parseGoogleSlidesFromRawContentToPlainText(slidesRes.data);
98
99
  }
99
100
  catch (slidesError) {
100
101
  console.log("Error using Google Slides API", slidesError);
@@ -1,4 +1,85 @@
1
- import type { docs_v1, sheets_v4, slides_v1 } from "googleapis";
2
- export declare function parseGoogleDocFromRawContentToPlainText(snapshotRawContent: docs_v1.Schema$Document): string;
3
- export declare function parseGoogleSheetsFromRawContentToPlainText(snapshotRawContent: sheets_v4.Schema$Spreadsheet): string;
4
- export declare function parseGoogleSlidesFromRawContentToPlainText(snapshotRawContent: slides_v1.Schema$Presentation): string;
1
+ interface GoogleDocsDocument {
2
+ body?: {
3
+ content?: Array<{
4
+ paragraph?: {
5
+ elements?: Array<{
6
+ textRun?: {
7
+ content?: string;
8
+ };
9
+ }>;
10
+ paragraphStyle?: {
11
+ headingId?: string;
12
+ namedStyleType?: string;
13
+ };
14
+ bullet?: {
15
+ nestingLevel?: number;
16
+ };
17
+ };
18
+ table?: {
19
+ tableRows?: Array<{
20
+ tableCells?: Array<{
21
+ content?: Array<{
22
+ paragraph?: {
23
+ elements?: Array<{
24
+ textRun?: {
25
+ content?: string;
26
+ };
27
+ }>;
28
+ };
29
+ }>;
30
+ }>;
31
+ }>;
32
+ };
33
+ sectionBreak?: unknown;
34
+ tableOfContents?: {
35
+ content?: Array<{
36
+ paragraph?: {
37
+ elements?: Array<{
38
+ textRun?: {
39
+ content?: string;
40
+ };
41
+ }>;
42
+ };
43
+ }>;
44
+ };
45
+ }>;
46
+ };
47
+ }
48
+ interface GoogleSheetsSpreadsheet {
49
+ sheets?: Array<{
50
+ properties?: {
51
+ title?: string;
52
+ };
53
+ data?: Array<{
54
+ rowData?: Array<{
55
+ values?: Array<{
56
+ formattedValue?: string;
57
+ userEnteredValue?: {
58
+ stringValue?: string;
59
+ numberValue?: number;
60
+ boolValue?: boolean;
61
+ };
62
+ }>;
63
+ }>;
64
+ }>;
65
+ }>;
66
+ }
67
+ interface GoogleSlidesPresentation {
68
+ slides?: Array<{
69
+ pageElements?: Array<{
70
+ shape?: {
71
+ text?: {
72
+ textElements?: Array<{
73
+ textRun?: {
74
+ content?: string;
75
+ };
76
+ }>;
77
+ };
78
+ };
79
+ }>;
80
+ }>;
81
+ }
82
+ export declare function parseGoogleDocFromRawContentToPlainText(snapshotRawContent: GoogleDocsDocument): string;
83
+ export declare function parseGoogleSheetsFromRawContentToPlainText(snapshotRawContent: GoogleSheetsSpreadsheet): string;
84
+ export declare function parseGoogleSlidesFromRawContentToPlainText(snapshotRawContent: GoogleSlidesPresentation): string;
85
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.50",
3
+ "version": "0.2.51",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,
@@ -55,7 +55,6 @@
55
55
  "date-fns": "^4.1.0",
56
56
  "docx": "^9.3.0",
57
57
  "dotenv": "^16.4.7",
58
- "googleapis": "^148.0.0",
59
58
  "json-schema-to-zod": "^2.5.0",
60
59
  "jsonwebtoken": "^9.0.2",
61
60
  "mammoth": "^1.4.27",