@pipedream/google_calendar 0.5.12 → 0.5.13
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.
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import googleCalendar from "../../google_calendar.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
|
|
4
|
+
const DEFAULT_CALENDAR_SAMPLE_LIMIT = 25;
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
key: "google_calendar-get-current-user",
|
|
8
|
+
name: "Get Current User",
|
|
9
|
+
description: "Retrieve information about the authenticated Google Calendar account, including the primary calendar (summary, timezone, ACL flags), a list of accessible calendars, user-level settings (timezone, locale, week start), and the color palette that controls events and calendars. Ideal for confirming which calendar account is in use, customizing downstream scheduling, or equipping LLMs with the user’s context (timezones, available calendars) prior to creating or updating events. [See the documentation](https://developers.google.com/calendar/api/v3/reference/calendars/get).",
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
type: "action",
|
|
12
|
+
annotations: {
|
|
13
|
+
destructiveHint: false,
|
|
14
|
+
openWorldHint: true,
|
|
15
|
+
readOnlyHint: true,
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
googleCalendar,
|
|
19
|
+
},
|
|
20
|
+
async run({ $ }) {
|
|
21
|
+
const [
|
|
22
|
+
primaryCalendar,
|
|
23
|
+
calendarList,
|
|
24
|
+
settings,
|
|
25
|
+
colors,
|
|
26
|
+
] = await Promise.all([
|
|
27
|
+
this.googleCalendar.getCalendar({
|
|
28
|
+
calendarId: "primary",
|
|
29
|
+
}),
|
|
30
|
+
this.googleCalendar.listCalendars({
|
|
31
|
+
maxResults: DEFAULT_CALENDAR_SAMPLE_LIMIT,
|
|
32
|
+
}),
|
|
33
|
+
this.googleCalendar.requestHandler({
|
|
34
|
+
api: constants.API.SETTINGS.NAME,
|
|
35
|
+
method: constants.API.SETTINGS.METHOD.LIST,
|
|
36
|
+
}),
|
|
37
|
+
this.googleCalendar.requestHandler({
|
|
38
|
+
api: constants.API.COLORS.NAME,
|
|
39
|
+
method: constants.API.COLORS.METHOD.GET,
|
|
40
|
+
}),
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const timezoneSetting = settings?.items?.find?.((setting) => setting.id === "timezone")?.value;
|
|
44
|
+
const localeSetting = settings?.items?.find?.((setting) => setting.id === "locale")?.value;
|
|
45
|
+
|
|
46
|
+
const summaryName = primaryCalendar?.summary || primaryCalendar?.id;
|
|
47
|
+
$.export("$summary", `Retrieved Google Calendar user ${summaryName}`);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
primaryCalendar,
|
|
51
|
+
calendars: calendarList?.items ?? [],
|
|
52
|
+
settings: settings?.items ?? [],
|
|
53
|
+
timezone: timezoneSetting || primaryCalendar?.timeZone,
|
|
54
|
+
locale: localeSetting,
|
|
55
|
+
colors,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
};
|