@pipedream/microsoft_outlook_calendar 8.4.0 → 8.5.1
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/package.json
CHANGED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createHash } from "crypto";
|
|
2
|
+
import common from "../common/common.mjs";
|
|
3
|
+
|
|
4
|
+
function makeStableId(notification) {
|
|
5
|
+
const rawId = notification.resourceData?.id;
|
|
6
|
+
if (rawId) {
|
|
7
|
+
return rawId.length <= 64
|
|
8
|
+
? rawId
|
|
9
|
+
: `del-${createHash("sha256").update(rawId)
|
|
10
|
+
.digest("hex")
|
|
11
|
+
.slice(0, 16)}`;
|
|
12
|
+
}
|
|
13
|
+
const key = `${notification.subscriptionId ?? ""}:${notification.resource ?? ""}`;
|
|
14
|
+
return `deleted-${createHash("sha256").update(key)
|
|
15
|
+
.digest("hex")
|
|
16
|
+
.slice(0, 16)}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function notificationTs(notification) {
|
|
20
|
+
const raw =
|
|
21
|
+
notification.resourceData?.lastModifiedDateTime ||
|
|
22
|
+
notification.resourceData?.createdDateTime;
|
|
23
|
+
return raw
|
|
24
|
+
? Date.parse(raw)
|
|
25
|
+
: Date.now();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
...common,
|
|
30
|
+
key: "microsoft_outlook_calendar-deleted-calendar-event",
|
|
31
|
+
name: "Calendar Event Deleted (Instant)",
|
|
32
|
+
props: {
|
|
33
|
+
...common.props,
|
|
34
|
+
userId: {
|
|
35
|
+
type: "string",
|
|
36
|
+
label: "User ID",
|
|
37
|
+
description: "Optional user ID or principal name for delegated/admin scenarios. When provided, subscribes to `/users/{userId}/events` instead of `/me/events`.",
|
|
38
|
+
optional: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
description: "Emit new event when a Microsoft Outlook Calendar event is deleted. Because deleted events cannot be re-fetched from the Outlook API after deletion, this trigger emits notification metadata only (not the full event object). The emitted payload includes the deleted event identifier (`eventId`), `changeType`, `subscriptionId`, `tenantId`, and `notificationTimestamp`. Downstream processors must rely solely on this metadata. [See the documentation](https://learn.microsoft.com/en-us/graph/api/resources/changenotification?view=graph-rest-1.0)",
|
|
42
|
+
version: "0.0.1",
|
|
43
|
+
type: "source",
|
|
44
|
+
hooks: {
|
|
45
|
+
...common.hooks,
|
|
46
|
+
async activate() {
|
|
47
|
+
const resource = this.userId
|
|
48
|
+
? `/users/${this.userId}/events`
|
|
49
|
+
: "/me/events";
|
|
50
|
+
await this.activate({
|
|
51
|
+
changeType: "deleted",
|
|
52
|
+
resource,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
async deactivate() {
|
|
56
|
+
await this.deactivate();
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
...common.methods,
|
|
61
|
+
async getSampleEvents() {
|
|
62
|
+
return {
|
|
63
|
+
value: [],
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
emitEvent(notification) {
|
|
67
|
+
const eventId = notification.resourceData?.id;
|
|
68
|
+
const id = makeStableId(notification);
|
|
69
|
+
const ts = notificationTs(notification);
|
|
70
|
+
this.$emit({
|
|
71
|
+
eventId,
|
|
72
|
+
changeType: notification.changeType,
|
|
73
|
+
subscriptionId: notification.subscriptionId,
|
|
74
|
+
tenantId: notification.tenantId,
|
|
75
|
+
notificationTimestamp: new Date(ts).toISOString(),
|
|
76
|
+
}, {
|
|
77
|
+
id,
|
|
78
|
+
summary: `Calendar event deleted (ID:${eventId ?? id})`,
|
|
79
|
+
ts,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
async run(event) {
|
|
84
|
+
if (event.interval_seconds || event.cron) {
|
|
85
|
+
await this.microsoftOutlook.renewHook({
|
|
86
|
+
hookId: this.db.get("hookId"),
|
|
87
|
+
data: {
|
|
88
|
+
expirationDateTime: this.getIntervalEnd(),
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (event.query && event.query.validationToken) {
|
|
94
|
+
this.http.respond({
|
|
95
|
+
status: 200,
|
|
96
|
+
headers: {
|
|
97
|
+
"Content-Type": "text/plain",
|
|
98
|
+
},
|
|
99
|
+
body: event.query.validationToken,
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
this.http.respond({
|
|
103
|
+
status: 202,
|
|
104
|
+
});
|
|
105
|
+
const eventBody = JSON.parse(event.bodyRaw);
|
|
106
|
+
for (const notification of eventBody.value) {
|
|
107
|
+
if (!notification.clientState || notification.clientState === this.db.get("clientState")) {
|
|
108
|
+
this.emitEvent(notification);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "microsoft_outlook_calendar-new-upcoming-event-polling",
|
|
6
6
|
name: "New Upcoming Calendar Event (Polling)",
|
|
7
7
|
description: "Emit new event based on a time interval before an upcoming calendar event. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-events)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.9",
|
|
9
9
|
type: "source",
|
|
10
10
|
dedupe: "unique",
|
|
11
11
|
props: {
|
|
@@ -20,7 +20,7 @@ export default {
|
|
|
20
20
|
pollingInfo: {
|
|
21
21
|
type: "alert",
|
|
22
22
|
alertType: "info",
|
|
23
|
-
content: "Since this source executes based on a timer, event emission may be slightly delayed. For example, if the source runs every 5 minutes, the delay may be up to 5 minutes.
|
|
23
|
+
content: "Since this source executes based on a timer, event emission may be slightly delayed. For example, if the source runs every 5 minutes, the delay may be up to 5 minutes.",
|
|
24
24
|
},
|
|
25
25
|
minutesBefore: {
|
|
26
26
|
type: "integer",
|
|
@@ -134,4 +134,3 @@ export default {
|
|
|
134
134
|
this._setEmittedEvents(emittedEvents);
|
|
135
135
|
},
|
|
136
136
|
};
|
|
137
|
-
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import common from "../common/common.mjs";
|
|
2
|
-
import taskScheduler from "@pipedream/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.12",
|
|
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
|
-
};
|