@credal/actions 0.2.84 → 0.2.85

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 (32) hide show
  1. package/dist/actions/autogen/templates.js +20 -0
  2. package/dist/actions/autogen/types.d.ts +23 -6
  3. package/dist/actions/autogen/types.js +17 -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/editAGoogleCalendarEvent.js +11 -3
  10. package/dist/actions/providers/google-oauth/getDriveContentById.d.ts +3 -0
  11. package/dist/actions/providers/google-oauth/getDriveContentById.js +161 -0
  12. package/dist/actions/providers/google-oauth/listCalendarEvents.js +17 -6
  13. package/dist/actions/providers/google-oauth/scheduleCalendarMeeting.js +3 -7
  14. package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.d.ts +3 -0
  15. package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.js +47 -0
  16. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.d.ts +3 -0
  17. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.js +110 -0
  18. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.d.ts +3 -0
  19. package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.js +78 -0
  20. package/dist/actions/providers/google-oauth/updateCalendarEvent.js +10 -2
  21. package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.d.ts +15 -0
  22. package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.js +129 -0
  23. package/dist/actions/providers/googlemaps/nearbysearch.d.ts +3 -0
  24. package/dist/actions/providers/googlemaps/nearbysearch.js +96 -0
  25. package/dist/actions/providers/snowflake/runSnowflakeQuery.js +6 -4
  26. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +3 -0
  27. package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.js +154 -0
  28. package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +3 -0
  29. package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +45 -0
  30. package/package.json +1 -1
  31. package/dist/actions/providers/jamf/types.d.ts +0 -8
  32. package/dist/actions/providers/jamf/types.js +0 -7
@@ -2814,6 +2814,10 @@ export const snowflakeRunSnowflakeQueryDefinition = {
2814
2814
  type: "string",
2815
2815
  description: "The name of the Snowflake account",
2816
2816
  },
2817
+ username: {
2818
+ type: "string",
2819
+ description: "The username of the Snowflake Credential (optional)",
2820
+ },
2817
2821
  outputFormat: {
2818
2822
  type: "string",
2819
2823
  description: "The format of the output",
@@ -4422,6 +4426,10 @@ export const googleOauthScheduleCalendarMeetingDefinition = {
4422
4426
  type: "boolean",
4423
4427
  description: "Whether to use Google Meet for the meeting",
4424
4428
  },
4429
+ timeZone: {
4430
+ type: "string",
4431
+ description: "The time zone for the meeting, IANA Time Zone identifier (e.g., 'America/New_York')",
4432
+ },
4425
4433
  },
4426
4434
  },
4427
4435
  output: {
@@ -4623,6 +4631,10 @@ export const googleOauthListCalendarEventsDefinition = {
4623
4631
  },
4624
4632
  },
4625
4633
  },
4634
+ timezone: {
4635
+ type: "string",
4636
+ description: "Timezone the user is currently based out of, given by their calender, follows the IANA Time Zone Database format, defaults to UTC if not defined",
4637
+ },
4626
4638
  error: {
4627
4639
  type: "string",
4628
4640
  description: "Error message if listing failed",
@@ -4697,6 +4709,10 @@ export const googleOauthUpdateCalendarEventDefinition = {
4697
4709
  },
4698
4710
  },
4699
4711
  },
4712
+ timeZone: {
4713
+ type: "string",
4714
+ description: "The time zone for the event, IANA Time Zone identifier (e.g., 'America/New_York')",
4715
+ },
4700
4716
  },
4701
4717
  },
4702
4718
  },
@@ -4787,6 +4803,10 @@ export const googleOauthEditAGoogleCalendarEventDefinition = {
4787
4803
  },
4788
4804
  },
4789
4805
  },
4806
+ timeZone: {
4807
+ type: "string",
4808
+ description: "The time zone for the event, IANA Time Zone identifier (e.g., 'America/New_York')",
4809
+ },
4790
4810
  },
4791
4811
  },
4792
4812
  output: {
@@ -60,10 +60,10 @@ export declare const AuthParamsSchema: z.ZodObject<{
60
60
  redirectUri: z.ZodOptional<z.ZodString>;
61
61
  }, "strip", z.ZodTypeAny, {
62
62
  subdomain?: string | undefined;
63
+ username?: string | undefined;
63
64
  authToken?: string | undefined;
64
65
  baseUrl?: string | undefined;
65
66
  apiKey?: string | undefined;
66
- username?: string | undefined;
67
67
  userAgent?: string | undefined;
68
68
  emailFrom?: string | undefined;
69
69
  emailReplyTo?: string | undefined;
@@ -79,10 +79,10 @@ export declare const AuthParamsSchema: z.ZodObject<{
79
79
  redirectUri?: string | undefined;
80
80
  }, {
81
81
  subdomain?: string | undefined;
82
+ username?: string | undefined;
82
83
  authToken?: string | undefined;
83
84
  baseUrl?: string | undefined;
84
85
  apiKey?: string | undefined;
85
- username?: string | undefined;
86
86
  userAgent?: string | undefined;
87
87
  emailFrom?: string | undefined;
88
88
  emailReplyTo?: string | undefined;
@@ -2805,6 +2805,7 @@ export declare const snowflakeRunSnowflakeQueryParamsSchema: z.ZodObject<{
2805
2805
  role: z.ZodOptional<z.ZodString>;
2806
2806
  query: z.ZodString;
2807
2807
  accountName: z.ZodString;
2808
+ username: z.ZodOptional<z.ZodString>;
2808
2809
  outputFormat: z.ZodOptional<z.ZodEnum<["json", "csv"]>>;
2809
2810
  limit: z.ZodOptional<z.ZodNumber>;
2810
2811
  codeInterpreterLimit: z.ZodOptional<z.ZodNumber>;
@@ -2816,6 +2817,7 @@ export declare const snowflakeRunSnowflakeQueryParamsSchema: z.ZodObject<{
2816
2817
  warehouse: string;
2817
2818
  limit?: number | undefined;
2818
2819
  role?: string | undefined;
2820
+ username?: string | undefined;
2819
2821
  outputFormat?: "json" | "csv" | undefined;
2820
2822
  codeInterpreterLimit?: number | undefined;
2821
2823
  codeInterpreterImageGenLimit?: number | undefined;
@@ -2826,6 +2828,7 @@ export declare const snowflakeRunSnowflakeQueryParamsSchema: z.ZodObject<{
2826
2828
  warehouse: string;
2827
2829
  limit?: number | undefined;
2828
2830
  role?: string | undefined;
2831
+ username?: string | undefined;
2829
2832
  outputFormat?: "json" | "csv" | undefined;
2830
2833
  codeInterpreterLimit?: number | undefined;
2831
2834
  codeInterpreterImageGenLimit?: number | undefined;
@@ -3205,6 +3208,7 @@ export declare const googleOauthScheduleCalendarMeetingParamsSchema: z.ZodObject
3205
3208
  description: z.ZodOptional<z.ZodString>;
3206
3209
  attendees: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
3207
3210
  useGoogleMeet: z.ZodOptional<z.ZodBoolean>;
3211
+ timeZone: z.ZodOptional<z.ZodString>;
3208
3212
  }, "strip", z.ZodTypeAny, {
3209
3213
  name: string;
3210
3214
  calendarId: string;
@@ -3213,6 +3217,7 @@ export declare const googleOauthScheduleCalendarMeetingParamsSchema: z.ZodObject
3213
3217
  description?: string | undefined;
3214
3218
  attendees?: string[] | undefined;
3215
3219
  useGoogleMeet?: boolean | undefined;
3220
+ timeZone?: string | undefined;
3216
3221
  }, {
3217
3222
  name: string;
3218
3223
  calendarId: string;
@@ -3221,6 +3226,7 @@ export declare const googleOauthScheduleCalendarMeetingParamsSchema: z.ZodObject
3221
3226
  description?: string | undefined;
3222
3227
  attendees?: string[] | undefined;
3223
3228
  useGoogleMeet?: boolean | undefined;
3229
+ timeZone?: string | undefined;
3224
3230
  }>;
3225
3231
  export type googleOauthScheduleCalendarMeetingParamsType = z.infer<typeof googleOauthScheduleCalendarMeetingParamsSchema>;
3226
3232
  export declare const googleOauthScheduleCalendarMeetingOutputSchema: z.ZodObject<{
@@ -3379,6 +3385,7 @@ export declare const googleOauthListCalendarEventsOutputSchema: z.ZodObject<{
3379
3385
  } | undefined;
3380
3386
  hangoutLink?: string | undefined;
3381
3387
  }>, "many">;
3388
+ timezone: z.ZodOptional<z.ZodString>;
3382
3389
  error: z.ZodOptional<z.ZodString>;
3383
3390
  }, "strip", z.ZodTypeAny, {
3384
3391
  success: boolean;
@@ -3405,6 +3412,7 @@ export declare const googleOauthListCalendarEventsOutputSchema: z.ZodObject<{
3405
3412
  hangoutLink?: string | undefined;
3406
3413
  }[];
3407
3414
  error?: string | undefined;
3415
+ timezone?: string | undefined;
3408
3416
  }, {
3409
3417
  success: boolean;
3410
3418
  events: {
@@ -3430,6 +3438,7 @@ export declare const googleOauthListCalendarEventsOutputSchema: z.ZodObject<{
3430
3438
  hangoutLink?: string | undefined;
3431
3439
  }[];
3432
3440
  error?: string | undefined;
3441
+ timezone?: string | undefined;
3433
3442
  }>;
3434
3443
  export type googleOauthListCalendarEventsOutputType = z.infer<typeof googleOauthListCalendarEventsOutputSchema>;
3435
3444
  export type googleOauthListCalendarEventsFunction = ActionFunction<googleOauthListCalendarEventsParamsType, AuthParamsType, googleOauthListCalendarEventsOutputType>;
@@ -3454,6 +3463,7 @@ export declare const googleOauthUpdateCalendarEventParamsSchema: z.ZodObject<{
3454
3463
  email?: string | undefined;
3455
3464
  displayName?: string | undefined;
3456
3465
  }>>;
3466
+ timeZone: z.ZodOptional<z.ZodString>;
3457
3467
  }, "strip", z.ZodTypeAny, {
3458
3468
  status?: string | undefined;
3459
3469
  description?: string | undefined;
@@ -3462,6 +3472,7 @@ export declare const googleOauthUpdateCalendarEventParamsSchema: z.ZodObject<{
3462
3472
  start?: string | undefined;
3463
3473
  end?: string | undefined;
3464
3474
  attendees?: string[] | undefined;
3475
+ timeZone?: string | undefined;
3465
3476
  organizer?: {
3466
3477
  email?: string | undefined;
3467
3478
  displayName?: string | undefined;
@@ -3474,6 +3485,7 @@ export declare const googleOauthUpdateCalendarEventParamsSchema: z.ZodObject<{
3474
3485
  start?: string | undefined;
3475
3486
  end?: string | undefined;
3476
3487
  attendees?: string[] | undefined;
3488
+ timeZone?: string | undefined;
3477
3489
  organizer?: {
3478
3490
  email?: string | undefined;
3479
3491
  displayName?: string | undefined;
@@ -3490,6 +3502,7 @@ export declare const googleOauthUpdateCalendarEventParamsSchema: z.ZodObject<{
3490
3502
  start?: string | undefined;
3491
3503
  end?: string | undefined;
3492
3504
  attendees?: string[] | undefined;
3505
+ timeZone?: string | undefined;
3493
3506
  organizer?: {
3494
3507
  email?: string | undefined;
3495
3508
  displayName?: string | undefined;
@@ -3506,6 +3519,7 @@ export declare const googleOauthUpdateCalendarEventParamsSchema: z.ZodObject<{
3506
3519
  start?: string | undefined;
3507
3520
  end?: string | undefined;
3508
3521
  attendees?: string[] | undefined;
3522
+ timeZone?: string | undefined;
3509
3523
  organizer?: {
3510
3524
  email?: string | undefined;
3511
3525
  displayName?: string | undefined;
@@ -3551,6 +3565,7 @@ export declare const googleOauthEditAGoogleCalendarEventParamsSchema: z.ZodObjec
3551
3565
  email?: string | undefined;
3552
3566
  displayName?: string | undefined;
3553
3567
  }>>;
3568
+ timeZone: z.ZodOptional<z.ZodString>;
3554
3569
  }, "strip", z.ZodTypeAny, {
3555
3570
  calendarId: string;
3556
3571
  eventId: string;
@@ -3561,6 +3576,7 @@ export declare const googleOauthEditAGoogleCalendarEventParamsSchema: z.ZodObjec
3561
3576
  start?: string | undefined;
3562
3577
  end?: string | undefined;
3563
3578
  attendees?: string[] | undefined;
3579
+ timeZone?: string | undefined;
3564
3580
  organizer?: {
3565
3581
  email?: string | undefined;
3566
3582
  displayName?: string | undefined;
@@ -3575,6 +3591,7 @@ export declare const googleOauthEditAGoogleCalendarEventParamsSchema: z.ZodObjec
3575
3591
  start?: string | undefined;
3576
3592
  end?: string | undefined;
3577
3593
  attendees?: string[] | undefined;
3594
+ timeZone?: string | undefined;
3578
3595
  organizer?: {
3579
3596
  email?: string | undefined;
3580
3597
  displayName?: string | undefined;
@@ -3664,19 +3681,19 @@ export declare const googleOauthCreateSpreadsheetParamsSchema: z.ZodObject<{
3664
3681
  timeZone: z.ZodOptional<z.ZodString>;
3665
3682
  autoRecalc: z.ZodOptional<z.ZodEnum<["ON_CHANGE", "MINUTE", "HOUR"]>>;
3666
3683
  }, "strip", z.ZodTypeAny, {
3667
- locale?: string | undefined;
3668
3684
  timeZone?: string | undefined;
3685
+ locale?: string | undefined;
3669
3686
  autoRecalc?: "ON_CHANGE" | "MINUTE" | "HOUR" | undefined;
3670
3687
  }, {
3671
- locale?: string | undefined;
3672
3688
  timeZone?: string | undefined;
3689
+ locale?: string | undefined;
3673
3690
  autoRecalc?: "ON_CHANGE" | "MINUTE" | "HOUR" | undefined;
3674
3691
  }>>;
3675
3692
  }, "strip", z.ZodTypeAny, {
3676
3693
  title: string;
3677
3694
  properties?: {
3678
- locale?: string | undefined;
3679
3695
  timeZone?: string | undefined;
3696
+ locale?: string | undefined;
3680
3697
  autoRecalc?: "ON_CHANGE" | "MINUTE" | "HOUR" | undefined;
3681
3698
  } | undefined;
3682
3699
  sheets?: {
@@ -3691,8 +3708,8 @@ export declare const googleOauthCreateSpreadsheetParamsSchema: z.ZodObject<{
3691
3708
  }, {
3692
3709
  title: string;
3693
3710
  properties?: {
3694
- locale?: string | undefined;
3695
3711
  timeZone?: string | undefined;
3712
+ locale?: string | undefined;
3696
3713
  autoRecalc?: "ON_CHANGE" | "MINUTE" | "HOUR" | undefined;
3697
3714
  } | undefined;
3698
3715
  sheets?: {
@@ -849,6 +849,7 @@ export const snowflakeRunSnowflakeQueryParamsSchema = z.object({
849
849
  role: z.string().describe("The snowflake role to use for executing the query").optional(),
850
850
  query: z.string().describe("The SQL query to execute"),
851
851
  accountName: z.string().describe("The name of the Snowflake account"),
852
+ username: z.string().describe("The username of the Snowflake Credential (optional)").optional(),
852
853
  outputFormat: z.enum(["json", "csv"]).describe("The format of the output").optional(),
853
854
  limit: z.number().describe("A limit on the number of rows to return").optional(),
854
855
  codeInterpreterLimit: z
@@ -1515,6 +1516,10 @@ export const googleOauthScheduleCalendarMeetingParamsSchema = z.object({
1515
1516
  .describe("The attendees of the meeting")
1516
1517
  .optional(),
1517
1518
  useGoogleMeet: z.boolean().describe("Whether to use Google Meet for the meeting").optional(),
1519
+ timeZone: z
1520
+ .string()
1521
+ .describe("The time zone for the meeting, IANA Time Zone identifier (e.g., 'America/New_York')")
1522
+ .optional(),
1518
1523
  });
1519
1524
  export const googleOauthScheduleCalendarMeetingOutputSchema = z.object({
1520
1525
  success: z.boolean().describe("Whether the meeting was scheduled successfully"),
@@ -1582,6 +1587,10 @@ export const googleOauthListCalendarEventsOutputSchema = z.object({
1582
1587
  })
1583
1588
  .describe("A calendar event"))
1584
1589
  .describe("List of events"),
1590
+ timezone: z
1591
+ .string()
1592
+ .describe("Timezone the user is currently based out of, given by their calender, follows the IANA Time Zone Database format, defaults to UTC if not defined")
1593
+ .optional(),
1585
1594
  error: z.string().describe("Error message if listing failed").optional(),
1586
1595
  });
1587
1596
  export const googleOauthUpdateCalendarEventParamsSchema = z.object({
@@ -1606,6 +1615,10 @@ export const googleOauthUpdateCalendarEventParamsSchema = z.object({
1606
1615
  })
1607
1616
  .describe("The new organizer of the event")
1608
1617
  .optional(),
1618
+ timeZone: z
1619
+ .string()
1620
+ .describe("The time zone for the event, IANA Time Zone identifier (e.g., 'America/New_York')")
1621
+ .optional(),
1609
1622
  })
1610
1623
  .describe("The fields to update on the event")
1611
1624
  .optional(),
@@ -1636,6 +1649,10 @@ export const googleOauthEditAGoogleCalendarEventParamsSchema = z.object({
1636
1649
  })
1637
1650
  .describe("The new organizer of the event")
1638
1651
  .optional(),
1652
+ timeZone: z
1653
+ .string()
1654
+ .describe("The time zone for the event, IANA Time Zone identifier (e.g., 'America/New_York')")
1655
+ .optional(),
1639
1656
  });
1640
1657
  export const googleOauthEditAGoogleCalendarEventOutputSchema = z.object({
1641
1658
  success: z.boolean().describe("Whether the event was edited successfully"),
@@ -8,30 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const axios_1 = __importDefault(require("axios"));
16
- function getConfluenceApi(baseUrl, username, apiToken) {
17
- const api = axios_1.default.create({
12
+ const axiosClient_1 = require("../../util/axiosClient");
13
+ function getConfluenceRequestConfig(baseUrl, username, apiToken) {
14
+ return {
18
15
  baseURL: baseUrl,
19
16
  headers: {
20
17
  Accept: "application/json",
21
- // Tokens are associated with a specific user.
22
18
  Authorization: `Basic ${Buffer.from(`${username}:${apiToken}`).toString("base64")}`,
23
19
  },
24
- });
25
- return api;
20
+ };
26
21
  }
27
22
  const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
28
- const { pageId, username, content, title } = params;
29
- const { baseUrl, authToken } = authParams;
30
- const api = getConfluenceApi(baseUrl, username, authToken);
23
+ const { pageId, content, title } = params;
24
+ const { baseUrl, authToken, username } = authParams;
25
+ if (!baseUrl || !authToken || !username) {
26
+ throw new Error("Missing required authentication information");
27
+ }
28
+ const config = getConfluenceRequestConfig(baseUrl, username, authToken);
31
29
  // Get current version number
32
- const response = yield api.get(`/api/v2/pages/${pageId}`);
30
+ const response = yield axiosClient_1.axiosClient.get(`/api/v2/pages/${pageId}`, config);
33
31
  const currVersion = response.data.version.number;
34
- yield api.put(`/api/v2/pages/${pageId}`, {
32
+ const payload = {
35
33
  id: pageId,
36
34
  status: "current",
37
35
  title,
@@ -42,6 +40,7 @@ const confluenceUpdatePage = (_a) => __awaiter(void 0, [_a], void 0, function* (
42
40
  version: {
43
41
  number: currVersion + 1,
44
42
  },
45
- });
43
+ };
44
+ yield axiosClient_1.axiosClient.put(`/api/v2/pages/${pageId}`, payload, config);
46
45
  });
47
46
  exports.default = confluenceUpdatePage;
@@ -0,0 +1,7 @@
1
+ import type { ActionFunction } from "../../autogen/types";
2
+ declare const fillTemplateAction: ActionFunction<{
3
+ template: string;
4
+ }, {
5
+ result: string;
6
+ }, unknown>;
7
+ export default fillTemplateAction;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const fillTemplateAction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ template }) {
13
+ // Simply return the template without any modification
14
+ return {
15
+ result: template,
16
+ };
17
+ });
18
+ exports.default = fillTemplateAction;
@@ -0,0 +1,3 @@
1
+ import type { genericUniversalTestActionFunction } from "../../autogen/types";
2
+ declare const genericApiCall: genericUniversalTestActionFunction;
3
+ export default genericApiCall;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
16
+ const genericApiCall = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, }) {
17
+ try {
18
+ const { endpoint, method, headers, body } = params;
19
+ const response = yield (0, axios_1.default)({
20
+ url: endpoint,
21
+ method,
22
+ headers,
23
+ data: method !== "GET" ? body : undefined,
24
+ });
25
+ return {
26
+ statusCode: response.status,
27
+ headers: response.headers,
28
+ data: response.data,
29
+ };
30
+ }
31
+ catch (error) {
32
+ if (axios_1.default.isAxiosError(error)) {
33
+ throw Error("Axios Error: " + (error.message || "Failed to make API call"));
34
+ }
35
+ throw Error("Error: " + (error || "Failed to make API call"));
36
+ }
37
+ });
38
+ exports.default = genericApiCall;
@@ -13,17 +13,25 @@ const editAGoogleCalendarEvent = (_a) => __awaiter(void 0, [_a], void 0, functio
13
13
  if (!authParams.authToken) {
14
14
  return { success: false, error: MISSING_AUTH_TOKEN, eventId: "", eventUrl: "" };
15
15
  }
16
- const { calendarId, eventId, title, description, start, end, location, attendees, status, organizer } = params;
16
+ const { calendarId, eventId, title, description, start, end, location, attendees, status, organizer, timeZone } = params;
17
17
  const url = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`;
18
18
  const body = {};
19
19
  if (title !== undefined)
20
20
  body.summary = title;
21
21
  if (description !== undefined)
22
22
  body.description = description;
23
- if (start !== undefined)
23
+ if (start !== undefined) {
24
24
  body.start = { dateTime: start };
25
- if (end !== undefined)
25
+ if (timeZone) {
26
+ body.start.timeZone = timeZone;
27
+ }
28
+ }
29
+ if (end !== undefined) {
26
30
  body.end = { dateTime: end };
31
+ if (timeZone) {
32
+ body.end.timeZone = timeZone;
33
+ }
34
+ }
27
35
  if (location !== undefined)
28
36
  body.location = location;
29
37
  if (attendees !== undefined)
@@ -0,0 +1,3 @@
1
+ import type { googleOauthGetDriveFileContentByIDFunction } from "../../autogen/types.js";
2
+ declare const getDriveFileContentByID: googleOauthGetDriveFileContentByIDFunction;
3
+ export default getDriveFileContentByID;
@@ -0,0 +1,161 @@
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 pdf from "pdf-parse/lib/pdf-parse.js";
11
+ import { axiosClient } from "../../util/axiosClient.js";
12
+ import mammoth from "mammoth";
13
+ import { MISSING_AUTH_TOKEN } from "../../util/missingAuthConstants.js";
14
+ const getDriveFileContentByID = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
15
+ if (!authParams.authToken) {
16
+ return { success: false, error: MISSING_AUTH_TOKEN };
17
+ }
18
+ const { fileId, limit } = params;
19
+ try {
20
+ // First, get file metadata to determine the file type
21
+ const metadataUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?fields=name,mimeType,size`;
22
+ const metadataRes = yield axiosClient.get(metadataUrl, {
23
+ headers: {
24
+ Authorization: `Bearer ${authParams.authToken}`,
25
+ },
26
+ });
27
+ const { name: fileName, mimeType, size } = metadataRes.data;
28
+ // Check if file is too large (50MB limit for safety)
29
+ if (size && parseInt(size) > 50 * 1024 * 1024) {
30
+ return {
31
+ success: false,
32
+ error: "File too large (>50MB)",
33
+ };
34
+ }
35
+ let content = "";
36
+ // Handle different file types - read content directly
37
+ if (mimeType === "application/vnd.google-apps.document") {
38
+ // Google Docs - download as plain text
39
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=txt`;
40
+ const downloadRes = yield axiosClient.get(downloadUrl, {
41
+ headers: {
42
+ Authorization: `Bearer ${authParams.authToken}`,
43
+ },
44
+ responseType: 'text',
45
+ });
46
+ content = downloadRes.data;
47
+ }
48
+ else if (mimeType === "application/vnd.google-apps.spreadsheet") {
49
+ // Google Sheets - download as CSV
50
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=csv`;
51
+ const downloadRes = yield axiosClient.get(downloadUrl, {
52
+ headers: {
53
+ Authorization: `Bearer ${authParams.authToken}`,
54
+ },
55
+ responseType: 'text',
56
+ });
57
+ content = downloadRes.data;
58
+ }
59
+ else if (mimeType === "application/vnd.google-apps.presentation") {
60
+ // Google Slides - download as plain text
61
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media&format=txt`;
62
+ const downloadRes = yield axiosClient.get(downloadUrl, {
63
+ headers: {
64
+ Authorization: `Bearer ${authParams.authToken}`,
65
+ },
66
+ responseType: 'text',
67
+ });
68
+ content = downloadRes.data;
69
+ }
70
+ else if (mimeType === "application/pdf") {
71
+ // PDF files - use pdf-parse
72
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
73
+ const downloadRes = yield axiosClient.get(downloadUrl, {
74
+ headers: {
75
+ Authorization: `Bearer ${authParams.authToken}`,
76
+ },
77
+ responseType: 'arraybuffer',
78
+ });
79
+ try {
80
+ const pdfData = yield pdf(downloadRes.data);
81
+ content = pdfData.text;
82
+ }
83
+ catch (pdfError) {
84
+ return {
85
+ success: false,
86
+ error: `Failed to parse PDF: ${pdfError instanceof Error ? pdfError.message : 'Unknown PDF error'}`,
87
+ };
88
+ }
89
+ }
90
+ else if (mimeType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ||
91
+ mimeType === "application/msword") {
92
+ // Word documents (.docx or .doc) - download and extract text using mammoth
93
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
94
+ const downloadRes = yield axiosClient.get(downloadUrl, {
95
+ headers: {
96
+ Authorization: `Bearer ${authParams.authToken}`,
97
+ },
98
+ responseType: 'arraybuffer',
99
+ });
100
+ try {
101
+ // mammoth works with .docx files. It will ignore formatting and return raw text
102
+ const result = yield mammoth.extractRawText({ buffer: Buffer.from(downloadRes.data) });
103
+ content = result.value; // raw text
104
+ }
105
+ catch (wordError) {
106
+ return {
107
+ success: false,
108
+ error: `Failed to parse Word document: ${wordError instanceof Error ? wordError.message : 'Unknown Word error'}`,
109
+ };
110
+ }
111
+ }
112
+ else if (mimeType === "text/plain" ||
113
+ mimeType === "text/html" ||
114
+ mimeType === "application/rtf" ||
115
+ (mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith("text/"))) {
116
+ // Text-based files
117
+ const downloadUrl = `https://www.googleapis.com/drive/v3/files/${encodeURIComponent(fileId)}?alt=media`;
118
+ const downloadRes = yield axiosClient.get(downloadUrl, {
119
+ headers: {
120
+ Authorization: `Bearer ${authParams.authToken}`,
121
+ },
122
+ responseType: 'text',
123
+ });
124
+ content = downloadRes.data;
125
+ }
126
+ else if (mimeType === null || mimeType === void 0 ? void 0 : mimeType.startsWith("image/")) {
127
+ // Skip images
128
+ return {
129
+ success: false,
130
+ error: "Image files are not supported for text extraction",
131
+ };
132
+ }
133
+ else {
134
+ // Unsupported file type
135
+ return {
136
+ success: false,
137
+ error: `Unsupported file type: ${mimeType}`,
138
+ };
139
+ }
140
+ content = content.trim();
141
+ const originalLength = content.length;
142
+ // Naive way to truncate content
143
+ if (limit && content.length > limit) {
144
+ content = content.substring(0, limit);
145
+ }
146
+ return {
147
+ success: true,
148
+ content,
149
+ fileName,
150
+ fileLength: originalLength,
151
+ };
152
+ }
153
+ catch (error) {
154
+ console.error("Error getting Google Drive file content", error);
155
+ return {
156
+ success: false,
157
+ error: error instanceof Error ? error.message : "Unknown error",
158
+ };
159
+ }
160
+ });
161
+ export default getDriveFileContentByID;
@@ -14,14 +14,23 @@ const listCalendarEvents = (_a) => __awaiter(void 0, [_a], void 0, function* ({
14
14
  return { success: false, error: MISSING_AUTH_TOKEN, events: [] };
15
15
  }
16
16
  const { calendarId, query, maxResults, timeMin, timeMax } = params;
17
- const url = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}/events`;
18
- const allEvents = [];
19
- let pageToken = undefined;
20
- let fetchedCount = 0;
21
- const max = maxResults !== null && maxResults !== void 0 ? maxResults : 250; // Default to 250 if not specified, Google API max is 250
22
17
  try {
18
+ // First, fetch the calendar's timezone
19
+ const calendarUrl = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}`;
20
+ const calendarRes = yield axiosClient.get(calendarUrl, {
21
+ headers: {
22
+ Authorization: `Bearer ${authParams.authToken}`,
23
+ },
24
+ });
25
+ const calendarTimezone = calendarRes.data.timeZone || "UTC";
26
+ // Now fetch the events
27
+ const eventsUrl = `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendarId)}/events`;
28
+ const allEvents = [];
29
+ let pageToken = undefined;
30
+ let fetchedCount = 0;
31
+ const max = maxResults !== null && maxResults !== void 0 ? maxResults : 250; // Default to 250 if not specified, Google API max is 250
23
32
  while (fetchedCount < max) {
24
- const res = yield axiosClient.get(url, {
33
+ const res = yield axiosClient.get(eventsUrl, {
25
34
  headers: {
26
35
  Authorization: `Bearer ${authParams.authToken}`,
27
36
  },
@@ -33,6 +42,7 @@ const listCalendarEvents = (_a) => __awaiter(void 0, [_a], void 0, function* ({
33
42
  orderBy: "startTime",
34
43
  timeMin,
35
44
  timeMax,
45
+ timeZone: calendarTimezone, // Include the calendar's timezone in the request
36
46
  },
37
47
  });
38
48
  const { items = [], nextPageToken = undefined } = res.data;
@@ -81,6 +91,7 @@ const listCalendarEvents = (_a) => __awaiter(void 0, [_a], void 0, function* ({
81
91
  return {
82
92
  success: true,
83
93
  events: allEvents,
94
+ timezone: calendarTimezone, // Include the calendar's timezone in the response
84
95
  };
85
96
  }
86
97
  catch (error) {