@pipedream/google_calendar 0.5.2 → 0.5.3

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/README.md +7 -16
  2. package/actions/{update-event-attendees/update-event-attendees.mjs → add-attendees-to-event/add-attendees-to-event.mjs} +11 -25
  3. package/actions/common/create-event-common.mjs +76 -33
  4. package/actions/create-event/create-event.mjs +110 -12
  5. package/actions/delete-event/delete-event.mjs +2 -2
  6. package/actions/get-calendar/get-calendar.mjs +1 -1
  7. package/actions/get-event/get-event.mjs +1 -1
  8. package/actions/list-calendars/list-calendars.mjs +4 -2
  9. package/actions/list-events/list-events.mjs +22 -19
  10. package/actions/query-free-busy-calendars/query-free-busy-calendars.mjs +1 -1
  11. package/actions/quick-add-event/quick-add-event.mjs +22 -3
  12. package/actions/update-event/update-event.mjs +33 -5
  13. package/common/constants.mjs +8 -0
  14. package/google_calendar.app.mjs +33 -64
  15. package/package.json +3 -2
  16. package/sources/common/common.mjs +2 -2
  17. package/sources/event-cancelled/event-cancelled.mjs +3 -1
  18. package/sources/event-cancelled/test-event.mjs +31 -0
  19. package/sources/event-ended/event-ended.mjs +3 -1
  20. package/sources/event-ended/test-event.mjs +31 -0
  21. package/sources/new-calendar/new-calendar.mjs +4 -1
  22. package/sources/new-calendar/test-event.mjs +18 -0
  23. package/sources/new-event-search/new-event-search.mjs +2 -2
  24. package/sources/new-or-updated-event-instant/new-or-updated-event-instant.mjs +1 -1
  25. package/sources/upcoming-event-alert/test-event.mjs +32 -0
  26. package/sources/upcoming-event-alert/upcoming-event-alert.mjs +17 -26
  27. package/actions/list-events-by-type/list-events-by-type.mjs +0 -56
  28. package/sources/event-start/event-start.mjs +0 -60
  29. package/sources/event-start/test-event.mjs +0 -32
  30. package/sources/new-event/new-event.mjs +0 -36
  31. package/sources/new-or-updated-event/new-or-updated-event.mjs +0 -48
  32. package/sources/upcoming-event-type-alert/upcoming-event-type-alert.mjs +0 -149
@@ -1,56 +0,0 @@
1
- import googleCalendar from "../../google_calendar.app.mjs";
2
- import utils from "../../common/utils.mjs";
3
-
4
- export default {
5
- key: "google_calendar-list-events-by-type",
6
- name: "List Calendar Events by Type",
7
- description: "Retrieve a list of events filtered by type (\"default\", \"focusTime\", \"outOfOffice\", \"workingLocation\") from the Google Calendar. [See the documentation](https://developers.google.com/calendar/api/v3/reference/events/list)",
8
- version: "0.0.1",
9
- type: "action",
10
- props: {
11
- googleCalendar,
12
- calendarId: {
13
- propDefinition: [
14
- googleCalendar,
15
- "calendarId",
16
- ],
17
- },
18
- eventTypes: {
19
- propDefinition: [
20
- googleCalendar,
21
- "eventTypes",
22
- ],
23
- },
24
- maxResults: {
25
- propDefinition: [
26
- googleCalendar,
27
- "maxResults",
28
- ],
29
- },
30
- },
31
- async run({ $ }) {
32
- const args = utils.filterEmptyValues({
33
- calendarId: this.calendarId,
34
- eventTypes: this.eventTypes,
35
- });
36
- const events = [];
37
- let total, done = false, count = 0;
38
- do {
39
- const response = await this.googleCalendar.listEvents(args);
40
- for (const item of response.items) {
41
- events.push(item);
42
- count++;
43
- if (this.maxResults && count >= this.maxResults) {
44
- done = true;
45
- break;
46
- }
47
- }
48
- total = response.items?.length;
49
- args.syncToken = response.nextSyncToken;
50
- } while (total && !done);
51
-
52
- $.export("$summary", `Successfully retrieved ${events.length} event(s)`);
53
-
54
- return events;
55
- },
56
- };
@@ -1,60 +0,0 @@
1
- import common from "../common/common.mjs";
2
- import sampleEmit from "./test-event.mjs";
3
-
4
- export default {
5
- ...common,
6
- key: "google_calendar-event-start",
7
- name: "New Event Start",
8
- description: "Emit new event when the specified time before the Google Calendar event starts",
9
- version: "0.1.8",
10
- type: "source",
11
- dedupe: "unique",
12
- props: {
13
- ...common.props,
14
- calendarId: {
15
- propDefinition: [
16
- common.props.googleCalendar,
17
- "calendarId",
18
- ],
19
- },
20
- minutesBefore: {
21
- type: "integer",
22
- label: "Minutes Before",
23
- description: "Emit the event this many minutes before the event starts",
24
- default: 5,
25
- },
26
- },
27
- methods: {
28
- ...common.methods,
29
- getMillisecondsBefore() {
30
- return +this.minutesBefore * 60 * 1000;
31
- },
32
- getConfig({
33
- now, intervalMs,
34
- }) {
35
- const {
36
- getMillisecondsBefore,
37
- calendarId,
38
- } = this;
39
-
40
- const timeMin = new Date(now.getTime() - getMillisecondsBefore()).toISOString();
41
- const timeMax = new Date(now.getTime() + intervalMs).toISOString();
42
- return {
43
- calendarId,
44
- timeMax,
45
- timeMin,
46
- singleEvents: true,
47
- orderBy: "startTime",
48
- };
49
- },
50
- isRelevant(event, {
51
- now, intervalMs,
52
- }) {
53
- const start = new Date(event?.start?.dateTime);
54
- const msFromStart = start.getTime() - now.getTime();
55
- return msFromStart > 0
56
- && msFromStart < (this.getMillisecondsBefore() + intervalMs);
57
- },
58
- },
59
- sampleEmit,
60
- };
@@ -1,32 +0,0 @@
1
- export default {
2
- "kind": "calendar#meeting",
3
- "etag": "\"3299999999966000\"",
4
- "id": "3459g2tr92dbuwecv8m939jplk",
5
- "status": "upcoming",
6
- "htmlLink": "https://www.google.com/calendar/event?eid=MzQ1OWcydHI5MmRidXlldm45bTg5MzlwamsgeHhudkBzYW5kYm94LmNvbQ",
7
- "created": "2025-09-13T08:25:45.000Z",
8
- "updated": "2025-09-13T08:25:45.983Z",
9
- "summary": "Sample Event 2005",
10
- "creator": {
11
- "email": "xhx.v@sandbox.com",
12
- "self": true
13
- },
14
- "organizer": {
15
- "email": "xhx.v@sandbox.com",
16
- "self": true
17
- },
18
- "start": {
19
- "dateTime": "2025-09-13T18:30:00+09:00",
20
- "timeZone": "Asia/Tokyo"
21
- },
22
- "end": {
23
- "dateTime": "2025-09-13T19:00:00+09:00",
24
- "timeZone": "Asia/Tokyo"
25
- },
26
- "iCalUID": "3459g2tr92dbuwecv8m939jplk@google.com",
27
- "sequence": 1,
28
- "reminders": {
29
- "useDefault": true
30
- },
31
- "eventType": "normal"
32
- }
@@ -1,36 +0,0 @@
1
- import common from "../common/common.mjs";
2
-
3
- export default {
4
- ...common,
5
- key: "google_calendar-new-event",
6
- name: "New Event Created",
7
- description: "Emit new event when a Google Calendar event is created",
8
- version: "0.1.7",
9
- type: "source",
10
- dedupe: "unique",
11
- props: {
12
- ...common.props,
13
- calendarId: {
14
- propDefinition: [
15
- common.props.googleCalendar,
16
- "calendarId",
17
- ],
18
- },
19
- },
20
- methods: {
21
- ...common.methods,
22
- getConfig({ past }) {
23
- const updatedMin = past.toISOString();
24
- return {
25
- calendarId: this.calendarId,
26
- updatedMin,
27
- singleEvents: true,
28
- orderBy: "startTime",
29
- };
30
- },
31
- isRelevant(event, { past }) {
32
- const created = new Date(event.created);
33
- return created > past && event.status !== "cancelled";
34
- },
35
- },
36
- };
@@ -1,48 +0,0 @@
1
- import common from "../common/common.mjs";
2
-
3
- export default {
4
- ...common,
5
- key: "google_calendar-new-or-updated-event",
6
- name: "New Created or Updated Event",
7
- description: "Emit new event when a Google Calendar events is created or updated (does not emit cancelled events)",
8
- version: "0.1.7",
9
- type: "source",
10
- dedupe: "unique",
11
- props: {
12
- ...common.props,
13
- calendarId: {
14
- propDefinition: [
15
- common.props.googleCalendar,
16
- "calendarId",
17
- ],
18
- },
19
- },
20
- methods: {
21
- ...common.methods,
22
- getConfig({ past }) {
23
- const updatedMin = past.toISOString();
24
- return {
25
- calendarId: this.calendarId,
26
- updatedMin,
27
- singleEvents: true,
28
- orderBy: "startTime",
29
- };
30
- },
31
- isRelevant(event) {
32
- return event.status !== "cancelled";
33
- },
34
- generateMeta(event) {
35
- const {
36
- id,
37
- summary,
38
- updated: tsString,
39
- } = event;
40
- const ts = Date.parse(tsString);
41
- return {
42
- id: `${id}-${ts}`,
43
- summary,
44
- ts,
45
- };
46
- },
47
- },
48
- };
@@ -1,149 +0,0 @@
1
- import taskScheduler from "../../../pipedream/sources/new-scheduled-tasks/new-scheduled-tasks.mjs";
2
- import googleCalendar from "../../google_calendar.app.mjs";
3
-
4
- export default {
5
- key: "google_calendar-upcoming-event-type-alert",
6
- name: "New Upcoming Event Type Alert",
7
- description: `Emit new event based on a time interval before an upcoming event of the specified type ("default", "focusTime", "outOfOffice", "workingLocation") in the calendar. This source uses Pipedream's Task Scheduler.
8
- [See the documentation](https://pipedream.com/docs/examples/waiting-to-execute-next-step-of-workflow/#step-1-create-a-task-scheduler-event-source)
9
- for more information and instructions for connecting your Pipedream account.`,
10
- version: "0.0.1",
11
- type: "source",
12
- props: {
13
- pipedream: taskScheduler.props.pipedream,
14
- googleCalendar,
15
- db: "$.service.db",
16
- http: "$.interface.http",
17
- calendarId: {
18
- propDefinition: [
19
- googleCalendar,
20
- "calendarId",
21
- ],
22
- },
23
- eventTypes: {
24
- propDefinition: [
25
- googleCalendar,
26
- "eventTypes",
27
- ],
28
- },
29
- time: {
30
- type: "integer",
31
- label: "Minutes Before",
32
- description: "Number of minutes to trigger before the start of the calendar event.",
33
- min: 0,
34
- reloadProps: true,
35
- },
36
- },
37
- async additionalProps() {
38
- const props = {};
39
- if (this.time > 0) {
40
- props.timer = {
41
- type: "$.interface.timer",
42
- description: "Poll the API to schedule alerts for any newly created events",
43
- default: {
44
- intervalSeconds: 60 * this.time,
45
- },
46
- };
47
- }
48
- return props;
49
- },
50
- hooks: {
51
- async deactivate() {
52
- const ids = this._getScheduledEventIds();
53
- if (!ids?.length) {
54
- return;
55
- }
56
- for (const id of ids) {
57
- if (await this.deleteEvent({
58
- body: {
59
- id,
60
- },
61
- })) {
62
- console.log("Cancelled scheduled event");
63
- }
64
- }
65
- this._setScheduledEventIds();
66
- },
67
- },
68
- methods: {
69
- ...taskScheduler.methods,
70
- _getScheduledEventIds() {
71
- return this.db.get("scheduledEventIds");
72
- },
73
- _setScheduledEventIds(ids) {
74
- this.db.set("scheduledEventIds", ids);
75
- },
76
- _getScheduledCalendarEventIds() {
77
- return this.db.get("scheduledCalendarEventIds");
78
- },
79
- _setScheduledCalendarEventIds(ids) {
80
- this.db.set("scheduledCalendarEventIds", ids);
81
- },
82
- _hasDeployed() {
83
- const result = this.db.get("hasDeployed");
84
- this.db.set("hasDeployed", true);
85
- return result;
86
- },
87
- subtractMinutes(date, minutes) {
88
- return date.getTime() - minutes * 60000;
89
- },
90
- async getCalendarEvents() {
91
- const calendarEvents = [];
92
- const params = {
93
- calendarId: this.calendarId,
94
- eventTypes: this.eventTypes,
95
- };
96
- do {
97
- const {
98
- data: {
99
- items, nextPageToken,
100
- },
101
- } = await this.googleCalendar.getEvents(params);
102
- if (items?.length) {
103
- calendarEvents.push(...items);
104
- }
105
- params.pageToken = nextPageToken;
106
- } while (params.pageToken);
107
- return calendarEvents;
108
- },
109
- },
110
- async run(event) {
111
- // self subscribe only on the first time
112
- if (!this._hasDeployed()) {
113
- await this.selfSubscribe();
114
- }
115
-
116
- const scheduledEventIds = this._getScheduledEventIds() || [];
117
-
118
- // incoming scheduled event
119
- if (event.$channel === this.selfChannel()) {
120
- const remainingScheduledEventIds = scheduledEventIds.filter((id) => id !== event["$id"]);
121
- this._setScheduledEventIds(remainingScheduledEventIds);
122
- this.emitEvent(event, `Upcoming ${event.summary} event`);
123
- return;
124
- }
125
-
126
- // schedule new events
127
- const scheduledCalendarEventIds = this._getScheduledCalendarEventIds() || {};
128
- const calendarEvents = await this.getCalendarEvents();
129
-
130
- for (const calendarEvent of calendarEvents) {
131
- const startTime = calendarEvent.start
132
- ? (new Date(calendarEvent.start.dateTime || calendarEvent.start.date))
133
- : null;
134
- if (!startTime
135
- || startTime.getTime() < Date.now()
136
- || scheduledCalendarEventIds[calendarEvent.id])
137
- {
138
- continue;
139
- }
140
- const later = new Date(this.subtractMinutes(startTime, this.time));
141
-
142
- const scheduledEventId = this.emitScheduleEvent(calendarEvent, later);
143
- scheduledEventIds.push(scheduledEventId);
144
- scheduledCalendarEventIds[calendarEvent.id] = true;
145
- }
146
- this._setScheduledEventIds(scheduledEventIds);
147
- this._setScheduledCalendarEventIds(scheduledCalendarEventIds);
148
- },
149
- };