@pipedream/google_calendar 0.5.11 → 0.5.12
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 +6 -1
- package/actions/create-event/create-event.mjs +6 -1
- package/actions/delete-event/delete-event.mjs +6 -1
- package/actions/get-calendar/get-calendar.mjs +6 -1
- package/actions/get-event/get-event.mjs +6 -1
- package/actions/list-calendars/list-calendars.mjs +6 -1
- package/actions/list-events/list-events.mjs +6 -1
- package/actions/query-free-busy-calendars/query-free-busy-calendars.mjs +6 -1
- package/actions/quick-add-event/quick-add-event.mjs +6 -1
- package/actions/update-event/update-event.mjs +6 -1
- package/package.json +2 -2
- package/sources/common/taskScheduler.mjs +147 -0
- package/sources/upcoming-event-alert/upcoming-event-alert.mjs +15 -10
|
@@ -5,7 +5,12 @@ 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.4",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
},
|
|
9
14
|
type: "action",
|
|
10
15
|
props: {
|
|
11
16
|
googleCalendar,
|
|
@@ -7,7 +7,12 @@ 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.7",
|
|
11
|
+
annotations: {
|
|
12
|
+
destructiveHint: false,
|
|
13
|
+
openWorldHint: true,
|
|
14
|
+
readOnlyHint: false,
|
|
15
|
+
},
|
|
11
16
|
type: "action",
|
|
12
17
|
props: {
|
|
13
18
|
googleCalendar,
|
|
@@ -4,7 +4,12 @@ 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.8",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: true,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: false,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
googleCalendar,
|
|
@@ -4,7 +4,12 @@ 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.9",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
googleCalendar,
|
|
@@ -4,7 +4,12 @@ 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.9",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
googleCalendar,
|
|
@@ -4,7 +4,12 @@ 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.9",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
googleCalendar,
|
|
@@ -6,7 +6,12 @@ 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.9",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: true,
|
|
14
|
+
},
|
|
10
15
|
type: "action",
|
|
11
16
|
props: {
|
|
12
17
|
googleCalendar,
|
|
@@ -4,7 +4,12 @@ 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.9",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
8
13
|
type: "action",
|
|
9
14
|
props: {
|
|
10
15
|
googleCalendar,
|
|
@@ -6,7 +6,12 @@ export default {
|
|
|
6
6
|
key: "google_calendar-quick-add-event",
|
|
7
7
|
name: "Add Quick Event",
|
|
8
8
|
description: "Create a quick event to the Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Events.html#quickAdd)",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.9",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
},
|
|
10
15
|
type: "action",
|
|
11
16
|
props: {
|
|
12
17
|
googleCalendar,
|
|
@@ -6,7 +6,12 @@ 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.11",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: true,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
},
|
|
10
15
|
type: "action",
|
|
11
16
|
props: {
|
|
12
17
|
googleCalendar,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/google_calendar",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.12",
|
|
4
4
|
"description": "Pipedream Google_calendar Components",
|
|
5
5
|
"main": "google_calendar.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@googleapis/calendar": "^1.0.2",
|
|
14
|
-
"@pipedream/platform": "^3.
|
|
14
|
+
"@pipedream/platform": "^3.1.0",
|
|
15
15
|
"color-2-name": "^1.4.4",
|
|
16
16
|
"lodash.get": "^4.4.2",
|
|
17
17
|
"moment-timezone": "^0.5.33",
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
methods: {
|
|
6
|
+
async _makeAPIRequest({
|
|
7
|
+
$ = this, apiKey, ...opts
|
|
8
|
+
}) {
|
|
9
|
+
if (!opts.headers) opts.headers = {};
|
|
10
|
+
opts.headers["Authorization"] = `Bearer ${apiKey}`;
|
|
11
|
+
opts.headers["Content-Type"] = "application/json";
|
|
12
|
+
opts.headers["user-agent"] = "@PipedreamHQ/pipedream v0.1";
|
|
13
|
+
const { path } = opts;
|
|
14
|
+
delete opts.path;
|
|
15
|
+
opts.url = `https://api.pipedream.com/v1${path[0] === "/"
|
|
16
|
+
? ""
|
|
17
|
+
: "/"
|
|
18
|
+
}${path}`;
|
|
19
|
+
return axios($, opts);
|
|
20
|
+
},
|
|
21
|
+
selfChannel() {
|
|
22
|
+
return "self";
|
|
23
|
+
},
|
|
24
|
+
queuedEventsChannel() {
|
|
25
|
+
return "$in";
|
|
26
|
+
},
|
|
27
|
+
async subscribe(emitter_id, listener_id, event_name = null, apiKey) {
|
|
28
|
+
let params = {
|
|
29
|
+
emitter_id,
|
|
30
|
+
listener_id,
|
|
31
|
+
};
|
|
32
|
+
if (event_name) {
|
|
33
|
+
params.event_name = event_name;
|
|
34
|
+
}
|
|
35
|
+
return await this._makeAPIRequest({
|
|
36
|
+
method: "POST",
|
|
37
|
+
path: "/subscriptions",
|
|
38
|
+
params,
|
|
39
|
+
apiKey,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
async selfSubscribe(apiKey) {
|
|
43
|
+
const isSubscribedToSelf = this.db.get("isSubscribedToSelf");
|
|
44
|
+
if (!isSubscribedToSelf) {
|
|
45
|
+
const componentId = process.env.PD_COMPONENT;
|
|
46
|
+
const selfChannel = this.selfChannel();
|
|
47
|
+
console.log(`Subscribing to ${selfChannel} channel for event source`);
|
|
48
|
+
console.log(
|
|
49
|
+
await this.subscribe(componentId, componentId, selfChannel, apiKey),
|
|
50
|
+
);
|
|
51
|
+
this.db.set("isSubscribedToSelf", true);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
emitScheduleEvent(event, timestamp) {
|
|
55
|
+
const selfChannel = this.selfChannel();
|
|
56
|
+
const epoch = Date.parse(timestamp);
|
|
57
|
+
const $id = uuid();
|
|
58
|
+
|
|
59
|
+
console.log(`Scheduled event to emit on: ${new Date(epoch)}`);
|
|
60
|
+
|
|
61
|
+
this.$emit(
|
|
62
|
+
{
|
|
63
|
+
...event,
|
|
64
|
+
$channel: selfChannel,
|
|
65
|
+
$id,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: selfChannel,
|
|
69
|
+
id: $id,
|
|
70
|
+
delivery_ts: epoch,
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return $id;
|
|
75
|
+
},
|
|
76
|
+
async deleteScheduledEvent(event, apiKey) {
|
|
77
|
+
const componentId = process.env.PD_COMPONENT;
|
|
78
|
+
const inChannel = this.queuedEventsChannel();
|
|
79
|
+
|
|
80
|
+
// The user must pass a scheduled event UUID they'd like to cancel
|
|
81
|
+
// We lookup the event by ID and delete it
|
|
82
|
+
const { id } = event.body;
|
|
83
|
+
|
|
84
|
+
// List events in the $in channel - the queue of scheduled events, to be emitted in the future
|
|
85
|
+
const events = await this.listEvents(
|
|
86
|
+
componentId,
|
|
87
|
+
inChannel,
|
|
88
|
+
apiKey,
|
|
89
|
+
);
|
|
90
|
+
console.log("Events: ", events);
|
|
91
|
+
|
|
92
|
+
// Find the event in the list by id
|
|
93
|
+
const eventToCancel = events.data.find((e) => {
|
|
94
|
+
const { metadata } = e;
|
|
95
|
+
return metadata.id === id;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
console.log("Event to cancel: ", eventToCancel);
|
|
99
|
+
|
|
100
|
+
if (!eventToCancel) {
|
|
101
|
+
console.log(`No event with ${id} found`);
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Delete the event
|
|
106
|
+
await this.deleteEvent(
|
|
107
|
+
componentId,
|
|
108
|
+
eventToCancel.id,
|
|
109
|
+
inChannel,
|
|
110
|
+
apiKey,
|
|
111
|
+
);
|
|
112
|
+
return true;
|
|
113
|
+
},
|
|
114
|
+
async listEvents(dcID, event_name, apiKey) {
|
|
115
|
+
return await this._makeAPIRequest({
|
|
116
|
+
path: `/sources/${dcID}/event_summaries`,
|
|
117
|
+
params: {
|
|
118
|
+
event_name,
|
|
119
|
+
},
|
|
120
|
+
apiKey,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
async deleteEvent(dcID, eventID, event_name, apiKey) {
|
|
124
|
+
return await this._makeAPIRequest({
|
|
125
|
+
method: "DELETE",
|
|
126
|
+
path: `/sources/${dcID}/events`,
|
|
127
|
+
params: {
|
|
128
|
+
start_id: eventID,
|
|
129
|
+
end_id: eventID,
|
|
130
|
+
event_name,
|
|
131
|
+
},
|
|
132
|
+
apiKey,
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
emitEvent(event, summary) {
|
|
136
|
+
const id = event.$id;
|
|
137
|
+
delete event.$channel;
|
|
138
|
+
delete event.$id;
|
|
139
|
+
|
|
140
|
+
this.$emit(event, {
|
|
141
|
+
summary: summary ?? JSON.stringify(event),
|
|
142
|
+
id,
|
|
143
|
+
ts: +new Date(),
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import taskScheduler from "../../../pipedream/sources/new-scheduled-tasks/new-scheduled-tasks.mjs";
|
|
2
1
|
import googleCalendar from "../../google_calendar.app.mjs";
|
|
2
|
+
import taskScheduler from "../common/taskScheduler.mjs";
|
|
3
3
|
import sampleEmit from "./test-event.mjs";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
key: "google_calendar-upcoming-event-alert",
|
|
7
7
|
name: "New Upcoming Event Alert",
|
|
8
|
-
description:
|
|
9
|
-
|
|
10
|
-
for more information and instructions for connecting your Pipedream account.`,
|
|
11
|
-
version: "0.0.10",
|
|
8
|
+
description: "Emit new event based on a time interval before an upcoming event in the calendar.",
|
|
9
|
+
version: "0.1.0",
|
|
12
10
|
type: "source",
|
|
13
11
|
props: {
|
|
14
|
-
pipedream: taskScheduler.props.pipedream,
|
|
15
12
|
googleCalendar,
|
|
16
13
|
db: "$.service.db",
|
|
17
14
|
http: "$.interface.http",
|
|
15
|
+
pipedreamApiKey: {
|
|
16
|
+
type: "string",
|
|
17
|
+
label: "Pipedream API Key",
|
|
18
|
+
description: "[Click here to find your Pipedream API key](https://pipedream.com/settings/user)",
|
|
19
|
+
secret: true,
|
|
20
|
+
},
|
|
18
21
|
calendarId: {
|
|
19
22
|
propDefinition: [
|
|
20
23
|
googleCalendar,
|
|
@@ -55,11 +58,11 @@ export default {
|
|
|
55
58
|
return;
|
|
56
59
|
}
|
|
57
60
|
for (const id of ids) {
|
|
58
|
-
if (await this.
|
|
61
|
+
if (await this.deleteScheduledEvent({
|
|
59
62
|
body: {
|
|
60
63
|
id,
|
|
61
64
|
},
|
|
62
|
-
})) {
|
|
65
|
+
}, this.pipedreamApiKey)) {
|
|
63
66
|
console.log("Cancelled scheduled event");
|
|
64
67
|
}
|
|
65
68
|
}
|
|
@@ -112,7 +115,7 @@ export default {
|
|
|
112
115
|
async run(event) {
|
|
113
116
|
// self subscribe only on the first time
|
|
114
117
|
if (!this._hasDeployed()) {
|
|
115
|
-
await this.selfSubscribe();
|
|
118
|
+
await this.selfSubscribe(this.pipedreamApiKey);
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
const scheduledEventIds = this._getScheduledEventIds() || [];
|
|
@@ -121,7 +124,9 @@ export default {
|
|
|
121
124
|
if (event.$channel === this.selfChannel()) {
|
|
122
125
|
const remainingScheduledEventIds = scheduledEventIds.filter((id) => id !== event["$id"]);
|
|
123
126
|
this._setScheduledEventIds(remainingScheduledEventIds);
|
|
124
|
-
this.emitEvent(event, `Upcoming ${event.summary
|
|
127
|
+
this.emitEvent(event, `Upcoming ${event.summary
|
|
128
|
+
? event.summary + " "
|
|
129
|
+
: ""}event`);
|
|
125
130
|
return;
|
|
126
131
|
}
|
|
127
132
|
|