Skip to content

Commit 650e4be

Browse files
committed
sources
1 parent 66b0e43 commit 650e4be

File tree

18 files changed

+529
-0
lines changed

18 files changed

+529
-0
lines changed

components/add_to_calendar_pro/add_to_calendar_pro.app.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,22 @@ export default {
319319
}
320320
}
321321
},
322+
createWebhook(opts = {}) {
323+
return this._makeRequest({
324+
path: "/webhook",
325+
method: "POST",
326+
...opts,
327+
});
328+
},
329+
deleteWebhook({
330+
hookId, ...opts
331+
}) {
332+
return this._makeRequest({
333+
path: `/webhook/${hookId}`,
334+
method: "DELETE",
335+
...opts,
336+
});
337+
},
322338
getGroup({
323339
groupProKey, ...opts
324340
}) {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import addToCalendarPro from "../../add_to_calendar_pro.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
props: {
6+
addToCalendarPro,
7+
db: "$.service.db",
8+
http: "$.interface.http",
9+
name: {
10+
type: "string",
11+
label: "Name",
12+
description: "The name of the webhook",
13+
},
14+
},
15+
hooks: {
16+
async activate() {
17+
const { id } = await this.addToCalendarPro.createWebhook({
18+
data: {
19+
name: this.name,
20+
active: true,
21+
payload_url: this.http.endpoint,
22+
trigger: this.getTrigger(),
23+
trigger_element: this.getTriggerElement(),
24+
},
25+
});
26+
this._setHookId(id);
27+
},
28+
async deactivate() {
29+
const hookId = this._getHookId();
30+
if (hookId) {
31+
await this.addToCalendarPro.deleteWebhook({
32+
hookId,
33+
});
34+
}
35+
},
36+
},
37+
methods: {
38+
_getHookId() {
39+
return this.db.get("hookId");
40+
},
41+
_setHookId(hookId) {
42+
this.db.set("hookId", hookId);
43+
},
44+
getTrigger() {
45+
throw new ConfigurationError("getTrigger must be implemented");
46+
},
47+
getTriggerElement() {
48+
throw new ConfigurationError("getTriggerElement must be implemented");
49+
},
50+
generateMeta() {
51+
throw new ConfigurationError("generateMeta must be implemented");
52+
},
53+
},
54+
async run(event) {
55+
const { body } = event;
56+
if (!body) {
57+
return;
58+
}
59+
const meta = this.generateMeta(body);
60+
this.$emit(body, meta);
61+
},
62+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "add_to_calendar_pro-event-deleted-instant",
7+
name: "Event Deleted (Instant)",
8+
description: "Emit new event when a new event is deleted in the system",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getTrigger() {
15+
return "delete";
16+
},
17+
getTriggerElement() {
18+
return "event";
19+
},
20+
generateMeta({ element_data: item }) {
21+
return {
22+
id: item.prokey,
23+
summary: `Event Deleted with ProKey: ${item.prokey}`,
24+
ts: Date.now(),
25+
};
26+
},
27+
},
28+
sampleEmit,
29+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
export default {
2+
"element_data": {
3+
"date_created": "2025-06-26T18:37:41.282Z",
4+
"date_updated": "2025-06-26T18:37:41.425Z",
5+
"iCalFileName": null,
6+
"recurrence": null,
7+
"recurrence_interval": 1,
8+
"recurrence_count": null,
9+
"recurrence_byDay": null,
10+
"recurrence_byMonthDay": null,
11+
"recurrence_byMonth": null,
12+
"recurrence_weekstart": null,
13+
"recurrence_simple_type": null,
14+
"dates": [
15+
{
16+
"name": "new event",
17+
"description": null,
18+
"startDate": "2025-06-27",
19+
"endDate": null,
20+
"startTime": null,
21+
"endTime": null,
22+
"timeZone": null,
23+
"location": null,
24+
"status": null,
25+
"availability": null,
26+
"organizer_name": null,
27+
"organizer_email": null,
28+
"attendee_name": null,
29+
"attendee_email": null
30+
}
31+
],
32+
"title_event_series": null,
33+
"rsvp_block": null,
34+
"cta_block": null,
35+
"rsvp": false,
36+
"cta": false,
37+
"layout": null,
38+
"status": "published",
39+
"hideButton": false,
40+
"simplified_recurrence": false,
41+
"sequence": "0",
42+
"distribution": true,
43+
"landingpage": null,
44+
"prokey": "76026233-8475-4f88-882a-b234bc7d654e",
45+
"event_group": "c020e405-e322-4c5c-8126-d3cf0411bac2"
46+
}
47+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "add_to_calendar_pro-event-group-deleted-instant",
7+
name: "Event Group Deleted (Instant)",
8+
description: "Emit new event when a new event is deleted in the system",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getTrigger() {
15+
return "delete";
16+
},
17+
getTriggerElement() {
18+
return "event_group";
19+
},
20+
generateMeta({ element_data: item }) {
21+
return {
22+
id: item.prokey,
23+
summary: `Event Group Deleted with ProKey: ${item.prokey}`,
24+
ts: Date.now(),
25+
};
26+
},
27+
},
28+
sampleEmit,
29+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default {
2+
"element_data": {
3+
"date_created": "2025-06-26T19:19:37.544Z",
4+
"date_updated": "2025-06-26T19:19:37.629Z",
5+
"name": "event group",
6+
"subscription": "no",
7+
"internal_note": null,
8+
"subscription_cal_url": null,
9+
"status": "published",
10+
"cta": false,
11+
"cta_block": null,
12+
"layout": null,
13+
"prokey": "0563721e-2885-4c69-a6a8-49123aab7294",
14+
"landingpage": null,
15+
"events": []
16+
}
17+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "add_to_calendar_pro-event-group-updated-instant",
7+
name: "Event Group Updated (Instant)",
8+
description: "Emit new event when a new event is updated in the system",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getTrigger() {
15+
return "update";
16+
},
17+
getTriggerElement() {
18+
return "event_group";
19+
},
20+
generateMeta({ element_data: item }) {
21+
const ts = Date.parse(item.date_updated);
22+
return {
23+
id: `${item.prokey}${ts}`,
24+
summary: `Event Group Updated with ProKey: ${item.prokey}`,
25+
ts,
26+
};
27+
},
28+
},
29+
sampleEmit,
30+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default {
2+
"element_data": {
3+
"date_created": "2025-06-26T18:37:16.627Z",
4+
"date_updated": "2025-06-26T19:10:00.280Z",
5+
"name": "My Group",
6+
"subscription": "no",
7+
"internal_note": null,
8+
"subscription_cal_url": null,
9+
"status": "published",
10+
"cta": false,
11+
"cta_block": null,
12+
"layout": null,
13+
"prokey": "c020e405-e322-4c5c-8126-d3cf0411bac2",
14+
"landingpage": null,
15+
"events": [
16+
"c6510c06-a277-4e1c-9baf-deec9c5507c7"
17+
]
18+
}
19+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import common from "../common/base.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "add_to_calendar_pro-event-updated-instant",
7+
name: "Event Updated (Instant)",
8+
description: "Emit new event when a new event is updated in the system",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getTrigger() {
15+
return "update";
16+
},
17+
getTriggerElement() {
18+
return "event";
19+
},
20+
generateMeta({ element_data: item }) {
21+
const ts = Date.parse(item.date_updated);
22+
return {
23+
id: `${item.prokey}${ts}`,
24+
summary: `Event Updated with ProKey: ${item.prokey}`,
25+
ts,
26+
};
27+
},
28+
},
29+
sampleEmit,
30+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
export default {
2+
"element_data": {
3+
"date_created": "2025-06-26T18:59:06.830Z",
4+
"date_updated": "2025-06-26T19:25:34.677Z",
5+
"iCalFileName": null,
6+
"recurrence": null,
7+
"recurrence_interval": null,
8+
"recurrence_count": null,
9+
"recurrence_byDay": null,
10+
"recurrence_byMonthDay": null,
11+
"recurrence_byMonth": null,
12+
"recurrence_weekstart": null,
13+
"recurrence_simple_type": null,
14+
"dates": [
15+
{
16+
"name": "my event updated",
17+
"description": null,
18+
"startDate": "2025-07-03",
19+
"endDate": null,
20+
"startTime": null,
21+
"endTime": null,
22+
"timeZone": "Etc/GMT",
23+
"location": null,
24+
"status": null,
25+
"availability": null,
26+
"organizer_name": "",
27+
"organizer_email": "",
28+
"attendee_name": null,
29+
"attendee_email": null
30+
}
31+
],
32+
"title_event_series": null,
33+
"rsvp_block": 227,
34+
"cta_block": null,
35+
"rsvp": true,
36+
"cta": false,
37+
"layout": null,
38+
"status": "published",
39+
"hideButton": false,
40+
"simplified_recurrence": true,
41+
"sequence": "0",
42+
"distribution": true,
43+
"landingpage": null,
44+
"prokey": "c6510c06-a277-4e1c-9baf-deec9c5507c7",
45+
"event_group": "c020e405-e322-4c5c-8126-d3cf0411bac2"
46+
}
47+
}

0 commit comments

Comments
 (0)