@credal/actions 0.2.62 → 0.2.64

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.
Files changed (30) hide show
  1. package/dist/actions/autogen/templates.js +8 -0
  2. package/dist/actions/autogen/types.d.ts +6 -0
  3. package/dist/actions/autogen/types.js +5 -0
  4. package/dist/actions/providers/confluence/updatePage.js +14 -15
  5. package/dist/actions/providers/generic/fillTemplateAction.d.ts +7 -0
  6. package/dist/actions/providers/generic/fillTemplateAction.js +18 -0
  7. package/dist/actions/providers/generic/genericApiCall.d.ts +3 -0
  8. package/dist/actions/providers/generic/genericApiCall.js +38 -0
  9. package/dist/actions/providers/google-oauth/getDriveContentById.d.ts +3 -0
  10. package/dist/actions/providers/google-oauth/getDriveContentById.js +161 -0
  11. package/dist/actions/providers/google-oauth/getDriveFileContentById.js +13 -90
  12. package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.d.ts +3 -0
  13. package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.js +47 -0
  14. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.d.ts +3 -0
  15. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.js +110 -0
  16. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.d.ts +3 -0
  17. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.js +78 -0
  18. package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.d.ts +15 -0
  19. package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.js +129 -0
  20. package/dist/actions/providers/googlemaps/nearbysearch.d.ts +3 -0
  21. package/dist/actions/providers/googlemaps/nearbysearch.js +96 -0
  22. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +3 -0
  23. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.js +154 -0
  24. package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +3 -0
  25. package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +45 -0
  26. package/dist/utils/google.d.ts +4 -0
  27. package/dist/utils/google.js +126 -0
  28. package/package.json +1 -1
  29. package/dist/actions/providers/jamf/types.d.ts +0 -8
  30. package/dist/actions/providers/jamf/types.js +0 -7
@@ -1,3 +1,13 @@
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 { isAxiosTimeoutError } from "../actions/util/axiosClient.js";
1
11
  // Helper function to parse Google Docs content to plain text
2
12
  export function parseGoogleDocFromRawContentToPlainText(snapshotRawContent) {
3
13
  var _a, _b, _c, _d, _e, _f;
@@ -168,3 +178,119 @@ export function parseGoogleSlidesFromRawContentToPlainText(snapshotRawContent) {
168
178
  }
169
179
  return slideContents.join("\n\n");
170
180
  }
181
+ /** Specific to google docs */
182
+ const GDRIVE_BASE_URL = "https://www.googleapis.com/drive/v3/files/";
183
+ /**
184
+ * Given a Google Doc file ID and an OAuth auth token, this function will fetch the
185
+ * contents of the Google Doc and recursively fetch all of the tab contents.
186
+ *
187
+ * @param {string} fileId - The ID of the Google Doc file
188
+ * @param {string} authToken - The OAuth token to use for authentication
189
+ * @param {AxiosInstance} axiosClient - The axios client to use for making requests
190
+ * @returns {Promise<string>} A promise that resolves with the text content of the doc
191
+ */
192
+ function getGoogleDocContentNoExport(fileId, authToken, axiosClient) {
193
+ return __awaiter(this, void 0, void 0, function* () {
194
+ const docsUrl = `https://docs.googleapis.com/v1/documents/${fileId}?includeTabsContent=true`;
195
+ const docsRes = yield axiosClient.get(docsUrl, {
196
+ headers: { Authorization: `Bearer ${authToken}` },
197
+ });
198
+ const getAllTabs = (tabs) => {
199
+ const allTabs = [];
200
+ tabs.forEach((tab) => {
201
+ allTabs.push(tab);
202
+ if (tab.childTabs) {
203
+ allTabs.push(...getAllTabs(tab.childTabs));
204
+ }
205
+ });
206
+ return allTabs;
207
+ };
208
+ const tabs = docsRes.data.tabs || [];
209
+ const allTabs = getAllTabs(tabs);
210
+ const tabContents = allTabs.map((tab) => parseGoogleDocFromRawContentToPlainText(tab.documentTab));
211
+ return tabContents.join("\n\n");
212
+ });
213
+ }
214
+ export function getGoogleDocContent(fileId, authToken, axiosClient, sharedDriveParams) {
215
+ return __awaiter(this, void 0, void 0, function* () {
216
+ try {
217
+ return yield getGoogleDocContentNoExport(fileId, authToken, axiosClient);
218
+ }
219
+ catch (docsError) {
220
+ if (isAxiosTimeoutError(docsError)) {
221
+ console.log("Request timed out using Google Docs API - dont retry");
222
+ throw new Error("Request timed out using Google Docs API");
223
+ }
224
+ else {
225
+ console.log("Error using Google Docs API", docsError);
226
+ // Fallback to Drive API export if Docs API fails
227
+ const exportUrl = `${GDRIVE_BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
228
+ const exportRes = yield axiosClient.get(exportUrl, {
229
+ headers: { Authorization: `Bearer ${authToken}` },
230
+ responseType: "text",
231
+ });
232
+ return exportRes.data;
233
+ }
234
+ }
235
+ });
236
+ }
237
+ export function getGoogleSheetContent(fileId, authToken, axiosClient, sharedDriveParams) {
238
+ return __awaiter(this, void 0, void 0, function* () {
239
+ try {
240
+ const sheetsUrl = `https://sheets.googleapis.com/v4/spreadsheets/${fileId}?includeGridData=true`;
241
+ const sheetsRes = yield axiosClient.get(sheetsUrl, {
242
+ headers: {
243
+ Authorization: `Bearer ${authToken}`,
244
+ },
245
+ });
246
+ return parseGoogleSheetsFromRawContentToPlainText(sheetsRes.data);
247
+ }
248
+ catch (sheetsError) {
249
+ if (isAxiosTimeoutError(sheetsError)) {
250
+ console.log("Request timed out using Google Sheets API - dont retry");
251
+ throw new Error("Request timed out using Google Sheets API");
252
+ }
253
+ else {
254
+ console.log("Error using Google Sheets API", sheetsError);
255
+ const exportUrl = `${GDRIVE_BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/csv${sharedDriveParams}`;
256
+ const exportRes = yield axiosClient.get(exportUrl, {
257
+ headers: { Authorization: `Bearer ${authToken}` },
258
+ responseType: "text",
259
+ });
260
+ return exportRes.data
261
+ .split("\n")
262
+ .map((line) => line.replace(/,+$/, ""))
263
+ .map((line) => line.replace(/,{2,}/g, ","))
264
+ .join("\n");
265
+ }
266
+ }
267
+ });
268
+ }
269
+ export function getGoogleSlidesContent(fileId, authToken, axiosClient, sharedDriveParams) {
270
+ return __awaiter(this, void 0, void 0, function* () {
271
+ try {
272
+ const slidesUrl = `https://slides.googleapis.com/v1/presentations/${fileId}`;
273
+ const slidesRes = yield axiosClient.get(slidesUrl, {
274
+ headers: {
275
+ Authorization: `Bearer ${authToken}`,
276
+ },
277
+ });
278
+ return parseGoogleSlidesFromRawContentToPlainText(slidesRes.data);
279
+ }
280
+ catch (slidesError) {
281
+ if (isAxiosTimeoutError(slidesError)) {
282
+ console.log("Request timed out using Google Slides API - dont retry");
283
+ throw new Error("Request timed out using Google Slides API");
284
+ }
285
+ else {
286
+ console.log("Error using Google Slides API", slidesError);
287
+ const exportUrl = `${GDRIVE_BASE_URL}${encodeURIComponent(fileId)}/export?mimeType=text/plain${sharedDriveParams}`;
288
+ const exportRes = yield axiosClient.get(exportUrl, {
289
+ headers: { Authorization: `Bearer ${authToken}` },
290
+ responseType: "text",
291
+ });
292
+ return exportRes.data;
293
+ }
294
+ }
295
+ });
296
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credal/actions",
3
- "version": "0.2.62",
3
+ "version": "0.2.64",
4
4
  "type": "module",
5
5
  "description": "AI Actions by Credal AI",
6
6
  "sideEffects": false,
@@ -1,8 +0,0 @@
1
- import { z } from "zod";
2
- export declare const TokenResponseSchema: z.ZodObject<{
3
- token: z.ZodString;
4
- }, "strip", z.ZodTypeAny, {
5
- token: string;
6
- }, {
7
- token: string;
8
- }>;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenResponseSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.TokenResponseSchema = zod_1.z.object({
6
- token: zod_1.z.string(),
7
- });