@credal/actions 0.2.138 → 0.2.140

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.
@@ -12,6 +12,8 @@ import mammoth from "mammoth";
12
12
  import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
13
13
  import { extractTextFromPdf } from "../../../utils/pdf.js";
14
14
  import { getGoogleDocContent, getGoogleSheetContent, getGoogleSlidesContent } from "../../../utils/google.js";
15
+ import { read, utils } from "xlsx";
16
+ import officeParser from "officeparser";
15
17
  const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
16
18
  var _b, _c, _d, _e;
17
19
  if (!authParams.authToken) {
@@ -116,6 +118,44 @@ const getDriveFileContentById = (_a) => __awaiter(void 0, [_a], void 0, function
116
118
  const rawContentBuffer = Buffer.from(bufferResults); // Convert rawContent ArrayBuffer to Buffer
117
119
  content = rawContentBuffer.toString("utf-8");
118
120
  }
121
+ else if (mimeType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
122
+ mimeType === "application/vnd.ms-excel") {
123
+ const downloadUrl = `${BASE_URL}${encodeURIComponent(params.fileId)}?alt=media${sharedDriveParam}`;
124
+ const downloadRes = yield axiosClient.get(downloadUrl, {
125
+ headers,
126
+ responseType: "arraybuffer",
127
+ });
128
+ // 1. Read the buffer into a workbook
129
+ const workbook = read(downloadRes.data, { type: "buffer" });
130
+ // 2. Convert all sheets to plain text (CSV-style)
131
+ let textOutput = "";
132
+ workbook.SheetNames.forEach(sheetName => {
133
+ const sheet = workbook.Sheets[sheetName];
134
+ const csv = utils.sheet_to_csv(sheet); // or sheet_to_json if you want arrays
135
+ textOutput += `\n--- Sheet: ${sheetName} ---\n${csv}`;
136
+ });
137
+ // textOutput now contains all sheet data as text
138
+ content = textOutput.trim();
139
+ }
140
+ else if (mimeType === "application/vnd.openxmlformats-officedocument.presentationml.presentation") {
141
+ // Handle modern PowerPoint files (.pptx only)
142
+ const downloadUrl = `${BASE_URL}${encodeURIComponent(params.fileId)}?alt=media${sharedDriveParam}`;
143
+ const downloadRes = yield axiosClient.get(downloadUrl, {
144
+ headers,
145
+ responseType: "arraybuffer",
146
+ });
147
+ try {
148
+ // officeparser expects a Buffer, so convert the ArrayBuffer
149
+ const buffer = Buffer.from(downloadRes.data);
150
+ content = yield officeParser.parseOfficeAsync(buffer);
151
+ }
152
+ catch (powerpointError) {
153
+ return {
154
+ success: false,
155
+ error: `Failed to parse PowerPoint document: ${powerpointError instanceof Error ? powerpointError.message : "Unknown PowerPoint error"}`,
156
+ };
157
+ }
158
+ }
119
159
  else {
120
160
  return { success: false, error: `Unsupported file type: ${mimeType}` };
121
161
  }
@@ -21,13 +21,17 @@ const searchAllSalesforceRecords = (_a) => __awaiter(void 0, [_a], void 0, funct
21
21
  .replace(/-/g, "\\-"); // Escape dashes
22
22
  let customObject = "";
23
23
  if (params.usesLightningKnowledge) {
24
- customObject = "Knowledge__kav(Article_Body__c, Title)";
24
+ customObject = `Knowledge__kav(Article_Body__c, Title),
25
+ FeedItem(Id, Body, Title, ParentId, Parent.Name, CreatedBy.Name, CreatedDate, CommentCount),
26
+ FeedComment(Id, CommentBody, FeedItemId, ParentId, CreatedBy.Name, CreatedDate),
27
+ EmailMessage(Id, Subject, TextBody, FromAddress, ToAddress, ParentId, CreatedDate, Incoming)`;
25
28
  }
26
29
  const url = `${baseUrl}/services/data/v64.0/search/?q=${encodeURIComponent(`FIND {${escapedKeyword}} IN ALL FIELDS RETURNING
27
30
  Contact(Id, FirstName, LastName, Email, Phone, Title, Department, Account.Name, CreatedDate, LastModifiedDate),
28
31
  Account(Id, Name, Type, Industry, Phone, Website, BillingCity, BillingState, Description, CreatedDate, LastModifiedDate),
29
32
  Lead(Id, FirstName, LastName, Email, Company, Status, LeadSource, CreatedDate),
30
33
  Opportunity(Id, Name, StageName, Amount, CloseDate, Account.Name, Description, CreatedDate),
34
+ Task(Id, Subject, Description, Status, WhatId, WhoId, ActivityDate, Account.Name),
31
35
  Case(Id, Subject, Status, Priority, Origin, Account.Name, Contact.Name, Description, CreatedDate) ${customObject ? ", " + customObject : ""} LIMIT ${params.limit && params.limit <= maxLimitValue ? params.limit : maxLimitValue}`)}`;
32
36
  try {
33
37
  const response = yield axiosClient.get(url, { headers: { Authorization: `Bearer ${authToken}` } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.138",
3
+ "version": "0.2.140",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,
@@ -67,12 +67,14 @@
67
67
  "mammoth": "^1.4.27",
68
68
  "mongodb": "^6.13.1",
69
69
  "node-forge": "^1.3.1",
70
+ "officeparser": "^5.2.0",
70
71
  "p-limit": "^7.1.1",
71
72
  "resend": "^4.7.0",
72
73
  "snowflake-sdk": "^2.0.2",
73
74
  "ts-node": "^10.9.2",
74
75
  "unpdf": "^1.2.2",
75
76
  "uuid": "^11.1.0",
77
+ "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
76
78
  "zod": "^3.25.0"
77
79
  }
78
80
  }