@pipedream/google_calendar 0.5.6 → 0.5.8
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.
- package/actions/add-attendees-to-event/add-attendees-to-event.mjs +1 -1
- package/actions/create-event/create-event.mjs +1 -1
- package/actions/delete-event/delete-event.mjs +1 -1
- package/actions/get-calendar/get-calendar.mjs +1 -1
- package/actions/get-event/get-event.mjs +1 -1
- package/actions/list-calendars/list-calendars.mjs +1 -1
- package/actions/list-events/list-events.mjs +1 -1
- package/actions/query-free-busy-calendars/query-free-busy-calendars.mjs +1 -1
- package/actions/quick-add-event/quick-add-event.mjs +1 -1
- package/actions/update-event/update-event.mjs +1 -1
- package/common/constants.mjs +5 -0
- package/package.json +1 -1
- package/sources/event-cancelled/event-cancelled.mjs +1 -1
- package/sources/event-ended/event-ended.mjs +1 -1
- package/sources/new-calendar/new-calendar.mjs +1 -1
- package/sources/new-event-search/new-event-search.mjs +1 -1
- package/sources/new-or-updated-event-instant/new-or-updated-event-instant.mjs +55 -41
- package/sources/upcoming-event-alert/upcoming-event-alert.mjs +1 -1
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "google_calendar-add-attendees-to-event",
|
|
6
6
|
name: "Add Attendees To Event",
|
|
7
7
|
description: "Add attendees to an existing event. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Events.html#update)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.3",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
googleCalendar,
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
key: "google_calendar-create-event",
|
|
8
8
|
name: "Create Event",
|
|
9
9
|
description: "Create an event in a Google Calendar. [See the documentation](https://developers.google.com/calendar/api/v3/reference/events/insert)",
|
|
10
|
-
version: "0.2.
|
|
10
|
+
version: "0.2.5",
|
|
11
11
|
type: "action",
|
|
12
12
|
props: {
|
|
13
13
|
googleCalendar,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_calendar-delete-event",
|
|
5
5
|
name: "Delete an Event",
|
|
6
6
|
description: "Delete an event from a Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Events.html#delete)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.7",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
googleCalendar,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_calendar-get-calendar",
|
|
5
5
|
name: "Retrieve Calendar Details",
|
|
6
6
|
description: "Retrieve calendar details of a Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Calendars.html#get)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.8",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
googleCalendar,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_calendar-get-event",
|
|
5
5
|
name: "Retrieve Event Details",
|
|
6
6
|
description: "Retrieve event details from Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Events.html#get)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.8",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
googleCalendar,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_calendar-list-calendars",
|
|
5
5
|
name: "List Calendars",
|
|
6
6
|
description: "Retrieve a list of calendars from Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Calendarlist.html#list)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.8",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
googleCalendar,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "google_calendar-list-events",
|
|
7
7
|
name: "List Events",
|
|
8
8
|
description: "Retrieve a list of event from the Google Calendar. [See the documentation](https://developers.google.com/calendar/api/v3/reference/events/list)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.8",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
googleCalendar,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "google_calendar-query-free-busy-calendars",
|
|
5
5
|
name: "Retrieve Free/Busy Calendar Details",
|
|
6
6
|
description: "Retrieve free/busy calendar details from Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Freebusy.html#query)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.8",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
googleCalendar,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "google_calendar-quick-add-event",
|
|
6
6
|
name: "Add Quick Event",
|
|
7
7
|
description: "Create a quick event to the Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Events.html#quickAdd)",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.7",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
googleCalendar,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "google_calendar-update-event",
|
|
7
7
|
name: "Update Event",
|
|
8
8
|
description: "Update an event from Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Events.html#update)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.10",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
googleCalendar,
|
package/common/constants.mjs
CHANGED
|
@@ -85,7 +85,12 @@ const REPEAT_FREQUENCIES = {
|
|
|
85
85
|
YEARLY: "year",
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
+
const WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS = 24 * 60 * 60 * 1000;
|
|
89
|
+
const WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS =
|
|
90
|
+
(WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS * 0.95) / 1000;
|
|
91
|
+
|
|
88
92
|
export default {
|
|
89
93
|
API,
|
|
90
94
|
REPEAT_FREQUENCIES,
|
|
95
|
+
WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS,
|
|
91
96
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "google_calendar-event-cancelled",
|
|
7
7
|
name: "New Cancelled Event",
|
|
8
8
|
description: "Emit new event when a Google Calendar event is cancelled or deleted",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.11",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
props: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "google_calendar-new-event-search",
|
|
6
6
|
name: "New Event Matching a Search",
|
|
7
7
|
description: "Emit new event when a Google Calendar event is created that matches a search",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.11",
|
|
9
9
|
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
11
11
|
props: {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { v4 as uuid } from "uuid";
|
|
2
2
|
import sampleEmit from "./test-event.mjs";
|
|
3
3
|
import googleCalendar from "../../google_calendar.app.mjs";
|
|
4
|
-
import
|
|
4
|
+
import constants from "../../common/constants.mjs";
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
key: "google_calendar-new-or-updated-event-instant",
|
|
8
8
|
type: "source",
|
|
9
9
|
name: "New Created or Updated Event (Instant)",
|
|
10
10
|
description: "Emit new event when a Google Calendar events is created or updated (does not emit cancelled events)",
|
|
11
|
-
version: "0.1.
|
|
11
|
+
version: "0.1.15",
|
|
12
12
|
dedupe: "unique",
|
|
13
13
|
props: {
|
|
14
14
|
googleCalendar,
|
|
@@ -38,7 +38,7 @@ export default {
|
|
|
38
38
|
description: "The Google Calendar API requires occasional renewal of push notification subscriptions. **This runs in the background, so you should not need to modify this schedule**.",
|
|
39
39
|
type: "$.interface.timer",
|
|
40
40
|
static: {
|
|
41
|
-
intervalSeconds:
|
|
41
|
+
intervalSeconds: constants.WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS,
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
},
|
|
@@ -66,7 +66,11 @@ export default {
|
|
|
66
66
|
await this.makeWatchRequest();
|
|
67
67
|
},
|
|
68
68
|
async deactivate() {
|
|
69
|
-
|
|
69
|
+
try {
|
|
70
|
+
await this.stopWatchRequest();
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.log(`Error deactivating webhook. ${e}`);
|
|
73
|
+
}
|
|
70
74
|
},
|
|
71
75
|
},
|
|
72
76
|
methods: {
|
|
@@ -199,16 +203,18 @@ export default {
|
|
|
199
203
|
}
|
|
200
204
|
return new Date(min);
|
|
201
205
|
},
|
|
202
|
-
|
|
203
|
-
const channelIds = [];
|
|
206
|
+
getCalendarIdForChannelId(incomingChannelId) {
|
|
204
207
|
for (const calendarId of this.calendarIds) {
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
if (this.db.get(`${calendarId}.channelId`) === incomingChannelId) {
|
|
209
|
+
return calendarId;
|
|
210
|
+
}
|
|
207
211
|
}
|
|
208
|
-
return
|
|
212
|
+
return null;
|
|
209
213
|
},
|
|
210
214
|
},
|
|
211
215
|
async run(event) {
|
|
216
|
+
let calendarId = null; // calendar ID matching incoming channel ID
|
|
217
|
+
|
|
212
218
|
// refresh watch
|
|
213
219
|
if (event.interval_seconds) {
|
|
214
220
|
// get time
|
|
@@ -224,9 +230,9 @@ export default {
|
|
|
224
230
|
}
|
|
225
231
|
} else {
|
|
226
232
|
// Verify channel ID
|
|
227
|
-
const channelIds = this.getChannelIds();
|
|
228
233
|
const incomingChannelId = event?.headers?.["x-goog-channel-id"];
|
|
229
|
-
|
|
234
|
+
calendarId = this.getCalendarIdForChannelId(incomingChannelId);
|
|
235
|
+
if (!calendarId) {
|
|
230
236
|
console.log(
|
|
231
237
|
`Unexpected channel ID ${incomingChannelId}. This likely means there are multiple, older subscriptions active.`,
|
|
232
238
|
);
|
|
@@ -252,41 +258,49 @@ export default {
|
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
// Fetch and emit events
|
|
255
|
-
|
|
261
|
+
const checkCalendarIds = calendarId
|
|
262
|
+
? [
|
|
263
|
+
calendarId,
|
|
264
|
+
]
|
|
265
|
+
: this.calendarIds;
|
|
266
|
+
for (const calendarId of checkCalendarIds) {
|
|
256
267
|
const syncToken = this.getNextSyncToken(calendarId);
|
|
257
268
|
let nextSyncToken = null;
|
|
258
269
|
let nextPageToken = null;
|
|
259
270
|
while (!nextSyncToken) {
|
|
260
|
-
|
|
261
|
-
data: syncData = {}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
pageToken: nextPageToken,
|
|
268
|
-
maxResults: 2500,
|
|
269
|
-
});
|
|
270
|
-
if (syncStatus === 410) {
|
|
271
|
-
console.log("Sync token invalid, resyncing");
|
|
272
|
-
nextSyncToken = await this.googleCalendar.fullSync(this.calendarId);
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
nextPageToken = syncData.nextPageToken;
|
|
276
|
-
nextSyncToken = syncData.nextSyncToken;
|
|
277
|
-
|
|
278
|
-
const { items: events = [] } = syncData;
|
|
279
|
-
events
|
|
280
|
-
.filter(this.isEventRelevant, this)
|
|
281
|
-
.forEach((event) => {
|
|
282
|
-
const { status } = event;
|
|
283
|
-
if (status === "cancelled") {
|
|
284
|
-
console.log("Event cancelled. Exiting.");
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
const meta = this.generateMeta(event);
|
|
288
|
-
this.$emit(event, meta);
|
|
271
|
+
try {
|
|
272
|
+
const { data: syncData = {} } = await this.googleCalendar.listEvents({
|
|
273
|
+
returnOnlyData: false,
|
|
274
|
+
calendarId,
|
|
275
|
+
syncToken,
|
|
276
|
+
pageToken: nextPageToken,
|
|
277
|
+
maxResults: 2500,
|
|
289
278
|
});
|
|
279
|
+
|
|
280
|
+
nextPageToken = syncData.nextPageToken;
|
|
281
|
+
nextSyncToken = syncData.nextSyncToken;
|
|
282
|
+
|
|
283
|
+
const { items: events = [] } = syncData;
|
|
284
|
+
events
|
|
285
|
+
.filter(this.isEventRelevant, this)
|
|
286
|
+
.forEach((event) => {
|
|
287
|
+
const { status } = event;
|
|
288
|
+
if (status === "cancelled") {
|
|
289
|
+
console.log("Event cancelled. Exiting.");
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const meta = this.generateMeta(event);
|
|
293
|
+
this.$emit(event, meta);
|
|
294
|
+
});
|
|
295
|
+
} catch (error) {
|
|
296
|
+
if (error === "Sync token is no longer valid, a full sync is required.") {
|
|
297
|
+
console.log("Sync token invalid, resyncing");
|
|
298
|
+
nextSyncToken = await this.googleCalendar.fullSync(calendarId);
|
|
299
|
+
break;
|
|
300
|
+
} else {
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
290
304
|
}
|
|
291
305
|
|
|
292
306
|
this.setNextSyncToken(calendarId, nextSyncToken);
|
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
description: `Emit new event based on a time interval before an upcoming event in the calendar. This source uses Pipedream's Task Scheduler.
|
|
9
9
|
[See the documentation](https://pipedream.com/docs/examples/waiting-to-execute-next-step-of-workflow/#step-1-create-a-task-scheduler-event-source)
|
|
10
10
|
for more information and instructions for connecting your Pipedream account.`,
|
|
11
|
-
version: "0.0.
|
|
11
|
+
version: "0.0.10",
|
|
12
12
|
type: "source",
|
|
13
13
|
props: {
|
|
14
14
|
pipedream: taskScheduler.props.pipedream,
|