@pipedream/microsoft_outlook_calendar 8.4.0 → 8.5.0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_outlook_calendar",
3
- "version": "8.4.0",
3
+ "version": "8.5.0",
4
4
  "description": "Pipedream Microsoft Outlook Calendar Components",
5
5
  "main": "microsoft_outlook_calendar.app.mjs",
6
6
  "keywords": [
@@ -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
+ };