@pipedream/microsoft_outlook_calendar 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/actions/create-calendar-event/create-calendar-event.mjs +111 -0
- package/actions/delete-calendar-event/delete-calendar-event.mjs +28 -0
- package/actions/update-calendar-event/update-calendar-event.mjs +142 -0
- package/microsoft_outlook_calendar.app.mjs +31 -0
- package/package.json +1 -1
- package/sources/common.mjs +10 -0
- package/sources/new-calendar-event/new-calendar-event.mjs +56 -0
- package/sources/new-upcoming-event/new-upcoming-event.mjs +92 -0
- package/sources/updated-calendar-event/updated-calendar-event.mjs +56 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
type: "action",
|
5
|
+
key: "microsoft_outlook_calendar-create-calendar-event",
|
6
|
+
version: "0.0.6",
|
7
|
+
name: "Create Calendar Event",
|
8
|
+
description: "Create an event in the user's default calendar. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-events)",
|
9
|
+
props: {
|
10
|
+
microsoftOutlook,
|
11
|
+
subject: {
|
12
|
+
label: "Subject",
|
13
|
+
description: "Subject of the event",
|
14
|
+
type: "string",
|
15
|
+
},
|
16
|
+
contentType: {
|
17
|
+
propDefinition: [
|
18
|
+
microsoftOutlook,
|
19
|
+
"contentType",
|
20
|
+
],
|
21
|
+
},
|
22
|
+
content: {
|
23
|
+
propDefinition: [
|
24
|
+
microsoftOutlook,
|
25
|
+
"content",
|
26
|
+
],
|
27
|
+
description: "Content",
|
28
|
+
},
|
29
|
+
timeZone: {
|
30
|
+
propDefinition: [
|
31
|
+
microsoftOutlook,
|
32
|
+
"timeZone",
|
33
|
+
],
|
34
|
+
},
|
35
|
+
start: {
|
36
|
+
propDefinition: [
|
37
|
+
microsoftOutlook,
|
38
|
+
"start",
|
39
|
+
],
|
40
|
+
},
|
41
|
+
end: {
|
42
|
+
propDefinition: [
|
43
|
+
microsoftOutlook,
|
44
|
+
"end",
|
45
|
+
],
|
46
|
+
},
|
47
|
+
attendees: {
|
48
|
+
propDefinition: [
|
49
|
+
microsoftOutlook,
|
50
|
+
"attendees",
|
51
|
+
],
|
52
|
+
},
|
53
|
+
location: {
|
54
|
+
propDefinition: [
|
55
|
+
microsoftOutlook,
|
56
|
+
"location",
|
57
|
+
],
|
58
|
+
},
|
59
|
+
isOnlineMeeting: {
|
60
|
+
propDefinition: [
|
61
|
+
microsoftOutlook,
|
62
|
+
"isOnlineMeeting",
|
63
|
+
],
|
64
|
+
},
|
65
|
+
expand: {
|
66
|
+
propDefinition: [
|
67
|
+
microsoftOutlook,
|
68
|
+
"expand",
|
69
|
+
],
|
70
|
+
description: "Additional event details, [See object definition](https://docs.microsoft.com/en-us/graph/api/resources/event)",
|
71
|
+
},
|
72
|
+
},
|
73
|
+
async run({ $ }) {
|
74
|
+
//RegExp to check time strings(yyyy-MM-ddThh:mm:ss)
|
75
|
+
const re = /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)$/;
|
76
|
+
if (!re.test(this.start) || !re.test(this.start)) {
|
77
|
+
throw new Error("Please provide both start and end props in 'yyyy-MM-ddThh:mm:ss'");
|
78
|
+
}
|
79
|
+
const data = {
|
80
|
+
subject: this.subject,
|
81
|
+
body: {
|
82
|
+
contentType: this.contentType ?? "HTML",
|
83
|
+
content: this.content,
|
84
|
+
},
|
85
|
+
start: {
|
86
|
+
dateTime: this.start,
|
87
|
+
timeZone: this.timeZone,
|
88
|
+
},
|
89
|
+
end: {
|
90
|
+
dateTime: this.end,
|
91
|
+
timeZone: this.timeZone,
|
92
|
+
},
|
93
|
+
location: {
|
94
|
+
displayName: this.location,
|
95
|
+
},
|
96
|
+
attendees: this.attendees.map((at) => ({
|
97
|
+
emailAddress: {
|
98
|
+
address: at,
|
99
|
+
},
|
100
|
+
})),
|
101
|
+
isOnlineMeeting: this.isOnlineMeeting,
|
102
|
+
...this.expand,
|
103
|
+
};
|
104
|
+
const response = await this.microsoftOutlook.createCalendarEvent({
|
105
|
+
$,
|
106
|
+
data,
|
107
|
+
});
|
108
|
+
$.export("$summary", "Calendar event has been created.");
|
109
|
+
return response;
|
110
|
+
},
|
111
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
type: "action",
|
5
|
+
key: "microsoft_outlook_calendar-delete-calendar-event",
|
6
|
+
version: "0.0.1",
|
7
|
+
name: "Delete Calendar Event",
|
8
|
+
description: "Delete an event in the user's default calendar. [See the documentation](https://learn.microsoft.com/en-us/graph/api/event-delete?view=graph-rest-1.0&tabs=http)",
|
9
|
+
props: {
|
10
|
+
microsoftOutlook,
|
11
|
+
eventId: {
|
12
|
+
propDefinition: [
|
13
|
+
microsoftOutlook,
|
14
|
+
"eventId",
|
15
|
+
],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
async run({ $ }) {
|
19
|
+
const response = await this.microsoftOutlook.deleteCalendarEvent({
|
20
|
+
$,
|
21
|
+
eventId: this.eventId,
|
22
|
+
});
|
23
|
+
|
24
|
+
$.export("$summary", `Successfully deleted calendar event with ID ${this.eventId}`);
|
25
|
+
|
26
|
+
return response;
|
27
|
+
},
|
28
|
+
};
|
@@ -0,0 +1,142 @@
|
|
1
|
+
import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
type: "action",
|
5
|
+
key: "microsoft_outlook_calendar-update-calendar-event",
|
6
|
+
version: "0.0.1",
|
7
|
+
name: "Update Calendar Event",
|
8
|
+
description: "Update an event in the user's default calendar. [See the documentation](https://learn.microsoft.com/en-us/graph/api/event-update?view=graph-rest-1.0&tabs=http)",
|
9
|
+
props: {
|
10
|
+
microsoftOutlook,
|
11
|
+
eventId: {
|
12
|
+
propDefinition: [
|
13
|
+
microsoftOutlook,
|
14
|
+
"eventId",
|
15
|
+
],
|
16
|
+
},
|
17
|
+
subject: {
|
18
|
+
label: "Subject",
|
19
|
+
description: "Subject of the event",
|
20
|
+
type: "string",
|
21
|
+
optional: true,
|
22
|
+
|
23
|
+
},
|
24
|
+
contentType: {
|
25
|
+
propDefinition: [
|
26
|
+
microsoftOutlook,
|
27
|
+
"contentType",
|
28
|
+
],
|
29
|
+
optional: true,
|
30
|
+
},
|
31
|
+
content: {
|
32
|
+
propDefinition: [
|
33
|
+
microsoftOutlook,
|
34
|
+
"content",
|
35
|
+
],
|
36
|
+
description: "Content",
|
37
|
+
optional: true,
|
38
|
+
},
|
39
|
+
timeZone: {
|
40
|
+
propDefinition: [
|
41
|
+
microsoftOutlook,
|
42
|
+
"timeZone",
|
43
|
+
],
|
44
|
+
optional: true,
|
45
|
+
},
|
46
|
+
start: {
|
47
|
+
propDefinition: [
|
48
|
+
microsoftOutlook,
|
49
|
+
"start",
|
50
|
+
],
|
51
|
+
optional: true,
|
52
|
+
},
|
53
|
+
end: {
|
54
|
+
propDefinition: [
|
55
|
+
microsoftOutlook,
|
56
|
+
"end",
|
57
|
+
],
|
58
|
+
optional: true,
|
59
|
+
},
|
60
|
+
attendees: {
|
61
|
+
propDefinition: [
|
62
|
+
microsoftOutlook,
|
63
|
+
"attendees",
|
64
|
+
],
|
65
|
+
optional: true,
|
66
|
+
},
|
67
|
+
location: {
|
68
|
+
propDefinition: [
|
69
|
+
microsoftOutlook,
|
70
|
+
"location",
|
71
|
+
],
|
72
|
+
optional: true,
|
73
|
+
},
|
74
|
+
isOnlineMeeting: {
|
75
|
+
propDefinition: [
|
76
|
+
microsoftOutlook,
|
77
|
+
"isOnlineMeeting",
|
78
|
+
],
|
79
|
+
optional: true,
|
80
|
+
},
|
81
|
+
expand: {
|
82
|
+
propDefinition: [
|
83
|
+
microsoftOutlook,
|
84
|
+
"expand",
|
85
|
+
],
|
86
|
+
description: "Additional event details, [See object definition](https://docs.microsoft.com/en-us/graph/api/resources/event)",
|
87
|
+
optional: true,
|
88
|
+
},
|
89
|
+
},
|
90
|
+
async run({ $ }) {
|
91
|
+
const data = {
|
92
|
+
subject: this.subject,
|
93
|
+
isOnlineMeeting: this.isOnlineMeeting,
|
94
|
+
...this.expand,
|
95
|
+
};
|
96
|
+
|
97
|
+
if (this.location) {
|
98
|
+
data.location = {
|
99
|
+
displayName: this.location,
|
100
|
+
};
|
101
|
+
}
|
102
|
+
|
103
|
+
if (this.contentType && this.content) {
|
104
|
+
data.body = {
|
105
|
+
contentType: this.contentType ?? "HTML",
|
106
|
+
content: this.content,
|
107
|
+
};
|
108
|
+
}
|
109
|
+
|
110
|
+
if (this.start && this.timeZone) {
|
111
|
+
data.start = {
|
112
|
+
dateTime: this.start,
|
113
|
+
timeZone: this.timeZone,
|
114
|
+
|
115
|
+
};
|
116
|
+
}
|
117
|
+
if (this.end && this.timeZone) {
|
118
|
+
data.end = {
|
119
|
+
dateTime: this.end,
|
120
|
+
timeZone: this.timeZone,
|
121
|
+
};
|
122
|
+
}
|
123
|
+
|
124
|
+
if (this.attendees) {
|
125
|
+
data.attendees = this.attendees.map((at) => ({
|
126
|
+
emailAddress: {
|
127
|
+
address: at,
|
128
|
+
},
|
129
|
+
}));
|
130
|
+
}
|
131
|
+
|
132
|
+
const response = await this.microsoftOutlook.updateCalendarEvent({
|
133
|
+
$,
|
134
|
+
eventId: this.eventId,
|
135
|
+
data,
|
136
|
+
});
|
137
|
+
|
138
|
+
$.export("$summary", `Successfully updated calendar event with ID ${response.id}`);
|
139
|
+
|
140
|
+
return response;
|
141
|
+
},
|
142
|
+
};
|
@@ -4,6 +4,19 @@ export default {
|
|
4
4
|
type: "app",
|
5
5
|
app: "microsoft_outlook_calendar",
|
6
6
|
propDefinitions: {
|
7
|
+
eventId: {
|
8
|
+
label: "Event ID",
|
9
|
+
description: "The event ID",
|
10
|
+
type: "string",
|
11
|
+
async options() {
|
12
|
+
const { value: events } = await this.listCalendarEvents();
|
13
|
+
|
14
|
+
return events.map((event) => ({
|
15
|
+
label: event.subject,
|
16
|
+
value: event.id,
|
17
|
+
}));
|
18
|
+
},
|
19
|
+
},
|
7
20
|
contentType: {
|
8
21
|
label: "Content Type",
|
9
22
|
description: "Content type (default `text`)",
|
@@ -132,6 +145,24 @@ export default {
|
|
132
145
|
...args,
|
133
146
|
});
|
134
147
|
},
|
148
|
+
async updateCalendarEvent({
|
149
|
+
eventId, ...args
|
150
|
+
}) {
|
151
|
+
return this._makeRequest({
|
152
|
+
method: "PATCH",
|
153
|
+
path: `/me/events/${eventId}`,
|
154
|
+
...args,
|
155
|
+
});
|
156
|
+
},
|
157
|
+
async deleteCalendarEvent({
|
158
|
+
eventId, ...args
|
159
|
+
}) {
|
160
|
+
return this._makeRequest({
|
161
|
+
method: "DELETE",
|
162
|
+
path: `/me/events/${eventId}`,
|
163
|
+
...args,
|
164
|
+
});
|
165
|
+
},
|
135
166
|
async listCalendarEvents(args = {}) {
|
136
167
|
return this._makeRequest({
|
137
168
|
method: "GET",
|
package/package.json
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
import common from "../common.mjs";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
...common,
|
5
|
+
key: "microsoft_outlook_calendar-new-calendar-event",
|
6
|
+
name: "New Calendar Event (Instant)",
|
7
|
+
description: "Emit new event when a new Calendar event is created",
|
8
|
+
version: "0.0.7",
|
9
|
+
type: "source",
|
10
|
+
hooks: {
|
11
|
+
...common.hooks,
|
12
|
+
async activate() {
|
13
|
+
await this.activate({
|
14
|
+
changeType: "created",
|
15
|
+
resource: "/me/events",
|
16
|
+
});
|
17
|
+
},
|
18
|
+
async deactivate() {
|
19
|
+
await this.deactivate();
|
20
|
+
},
|
21
|
+
},
|
22
|
+
methods: {
|
23
|
+
...common.methods,
|
24
|
+
async getSampleEvents({ pageSize }) {
|
25
|
+
return this.microsoftOutlook.listCalendarEvents({
|
26
|
+
params: {
|
27
|
+
$top: pageSize,
|
28
|
+
$orderby: "createdDateTime desc",
|
29
|
+
},
|
30
|
+
});
|
31
|
+
},
|
32
|
+
emitEvent(item) {
|
33
|
+
this.$emit({
|
34
|
+
message: item,
|
35
|
+
}, this.generateMeta(item));
|
36
|
+
},
|
37
|
+
generateMeta(item) {
|
38
|
+
return {
|
39
|
+
id: item.id,
|
40
|
+
summary: `New calendar event (ID:${item.id})`,
|
41
|
+
ts: Date.parse(item.createdDateTime),
|
42
|
+
};
|
43
|
+
},
|
44
|
+
},
|
45
|
+
async run(event) {
|
46
|
+
await this.run({
|
47
|
+
event,
|
48
|
+
emitFn: async ({ resourceId } = {}) => {
|
49
|
+
const item = await this.microsoftOutlook.getCalendarEvent({
|
50
|
+
eventId: resourceId,
|
51
|
+
});
|
52
|
+
this.emitEvent(item);
|
53
|
+
},
|
54
|
+
});
|
55
|
+
},
|
56
|
+
};
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import common from "../common.mjs";
|
2
|
+
import taskScheduler from "../../../pipedream/sources/new-scheduled-tasks/new-scheduled-tasks.mjs";
|
3
|
+
|
4
|
+
export default {
|
5
|
+
...common,
|
6
|
+
key: "microsoft_outlook_calendar-new-upcoming-event",
|
7
|
+
name: "New Upcoming Calendar Event",
|
8
|
+
description: "Emit new event when a Calendar event is upcoming, this source is using `reminderMinutesBeforeStart` property of the event to determine the time it should emit.",
|
9
|
+
version: "0.0.3",
|
10
|
+
type: "source",
|
11
|
+
props: {
|
12
|
+
...common.props,
|
13
|
+
pipedream: taskScheduler.props.pipedream,
|
14
|
+
},
|
15
|
+
hooks: {
|
16
|
+
...common.hooks,
|
17
|
+
async activate() {
|
18
|
+
await this.activate({
|
19
|
+
changeType: "updated",
|
20
|
+
resource: "/me/events",
|
21
|
+
});
|
22
|
+
},
|
23
|
+
async deactivate() {
|
24
|
+
await this.deactivate();
|
25
|
+
},
|
26
|
+
},
|
27
|
+
methods: {
|
28
|
+
...taskScheduler.methods,
|
29
|
+
...common.methods,
|
30
|
+
_hasDeployed() {
|
31
|
+
const result = this.db.get("hasDeployed");
|
32
|
+
this.db.set("hasDeployed", true);
|
33
|
+
return result;
|
34
|
+
},
|
35
|
+
subtractMinutes(date, minutes) {
|
36
|
+
return date.getTime() - minutes * 60000;
|
37
|
+
},
|
38
|
+
async getSampleEvents({ pageSize }) {
|
39
|
+
return this.microsoftOutlook.listCalendarEvents({
|
40
|
+
params: {
|
41
|
+
$top: pageSize,
|
42
|
+
$orderby: "lastModifiedDateTime desc",
|
43
|
+
},
|
44
|
+
});
|
45
|
+
},
|
46
|
+
emitEvent(item) {
|
47
|
+
this.$emit({
|
48
|
+
message: item,
|
49
|
+
}, this.generateMeta(item));
|
50
|
+
},
|
51
|
+
generateMeta(item) {
|
52
|
+
return {
|
53
|
+
id: item.id,
|
54
|
+
summary: `Upcoming event - ${item.subject}`,
|
55
|
+
ts: +Date.parse(item.createdDateTime),
|
56
|
+
};
|
57
|
+
},
|
58
|
+
},
|
59
|
+
async run(event) {
|
60
|
+
if (event.$channel === this.selfChannel()) {
|
61
|
+
const item = await this.microsoftOutlook.getCalendarEvent({
|
62
|
+
eventId: event.eventId,
|
63
|
+
});
|
64
|
+
// checking if the event was modified after this scheduling
|
65
|
+
if (item.lastModifiedDateTime === event.lastModifiedControl) {
|
66
|
+
this.emitEvent(item);
|
67
|
+
}
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
await this.run({
|
71
|
+
event,
|
72
|
+
emitFn: async ({ resourceId } = {}) => {
|
73
|
+
if (!this._hasDeployed()) {
|
74
|
+
await this.selfSubscribe();
|
75
|
+
}
|
76
|
+
const item = await this.microsoftOutlook.getCalendarEvent({
|
77
|
+
eventId: resourceId,
|
78
|
+
});
|
79
|
+
if (event.$channel !== this.selfChannel()) {
|
80
|
+
const startTime = new Date(item.start.dateTime || item.start.date);
|
81
|
+
const reminderMinutesBeforeStart = item.reminderMinutesBeforeStart || 15;
|
82
|
+
const later = new Date(this.subtractMinutes(startTime, reminderMinutesBeforeStart));
|
83
|
+
const newEvent = {
|
84
|
+
lastModifiedControl: item.lastModifiedDateTime,
|
85
|
+
eventId: resourceId,
|
86
|
+
};
|
87
|
+
this.emitScheduleEvent(newEvent, later);
|
88
|
+
}
|
89
|
+
},
|
90
|
+
});
|
91
|
+
},
|
92
|
+
};
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import common from "../common.mjs";
|
2
|
+
|
3
|
+
export default {
|
4
|
+
...common,
|
5
|
+
key: "microsoft_outlook_calendar-updated-calendar-event",
|
6
|
+
name: "New Calendar Event Update (Instant)",
|
7
|
+
description: "Emit new event when a Calendar event is updated",
|
8
|
+
version: "0.0.7",
|
9
|
+
type: "source",
|
10
|
+
hooks: {
|
11
|
+
...common.hooks,
|
12
|
+
async activate() {
|
13
|
+
await this.activate({
|
14
|
+
changeType: "updated",
|
15
|
+
resource: "/me/events",
|
16
|
+
});
|
17
|
+
},
|
18
|
+
async deactivate() {
|
19
|
+
await this.deactivate();
|
20
|
+
},
|
21
|
+
},
|
22
|
+
methods: {
|
23
|
+
...common.methods,
|
24
|
+
async getSampleEvents({ pageSize }) {
|
25
|
+
return this.microsoftOutlook.listCalendarEvents({
|
26
|
+
params: {
|
27
|
+
$top: pageSize,
|
28
|
+
$orderby: "lastModifiedDateTime desc",
|
29
|
+
},
|
30
|
+
});
|
31
|
+
},
|
32
|
+
emitEvent(item) {
|
33
|
+
this.$emit({
|
34
|
+
message: item,
|
35
|
+
}, this.generateMeta(item));
|
36
|
+
},
|
37
|
+
generateMeta(item) {
|
38
|
+
return {
|
39
|
+
id: item.id,
|
40
|
+
summary: `Calendar event updated (ID:${item.id})`,
|
41
|
+
ts: Date.parse(item.createdDateTime),
|
42
|
+
};
|
43
|
+
},
|
44
|
+
},
|
45
|
+
async run(event) {
|
46
|
+
await this.run({
|
47
|
+
event,
|
48
|
+
emitFn: async ({ resourceId } = {}) => {
|
49
|
+
const item = await this.microsoftOutlook.getCalendarEvent({
|
50
|
+
eventId: resourceId,
|
51
|
+
});
|
52
|
+
this.emitEvent(item);
|
53
|
+
},
|
54
|
+
});
|
55
|
+
},
|
56
|
+
};
|