@activepieces/piece-google-calendar 0.5.8 → 0.6.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 +9 -8
- package/src/i18n/fr.json +17 -17
- package/src/index.js +18 -1
- package/src/index.js.map +1 -1
- package/src/lib/actions/find-busy-free-periods.d.ts +5 -0
- package/src/lib/actions/find-busy-free-periods.js +77 -0
- package/src/lib/actions/find-busy-free-periods.js.map +1 -0
- package/src/lib/actions/get-event-by-id.d.ts +6 -0
- package/src/lib/actions/get-event-by-id.js +93 -0
- package/src/lib/actions/get-event-by-id.js.map +1 -0
- package/src/lib/common/helper.d.ts +4 -0
- package/src/lib/common/helper.js +62 -0
- package/src/lib/common/helper.js.map +1 -1
- package/src/lib/common/index.d.ts +1 -0
- package/src/lib/common/index.js +29 -0
- package/src/lib/common/index.js.map +1 -1
- package/src/lib/triggers/event-cancelled.d.ts +17 -0
- package/src/lib/triggers/event-cancelled.js +165 -0
- package/src/lib/triggers/event-cancelled.js.map +1 -0
- package/src/lib/triggers/event-ends.d.ts +14 -0
- package/src/lib/triggers/event-ends.js +167 -0
- package/src/lib/triggers/event-ends.js.map +1 -0
- package/src/lib/triggers/event-start-time-before.d.ts +20 -0
- package/src/lib/triggers/event-start-time-before.js +161 -0
- package/src/lib/triggers/event-start-time-before.js.map +1 -0
- package/src/lib/triggers/new-calendar.d.ts +14 -0
- package/src/lib/triggers/new-calendar.js +151 -0
- package/src/lib/triggers/new-calendar.js.map +1 -0
- package/src/lib/triggers/new-event-matching-search.d.ts +17 -0
- package/src/lib/triggers/new-event-matching-search.js +185 -0
- package/src/lib/triggers/new-event-matching-search.js.map +1 -0
- package/src/lib/triggers/new-event.d.ts +17 -0
- package/src/lib/triggers/new-event.js +161 -0
- package/src/lib/triggers/new-event.js.map +1 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventCancelled = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_framework_2 = require("@activepieces/pieces-framework");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const __1 = require("../../");
|
|
9
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
|
+
const pieces_common_2 = require("@activepieces/pieces-common");
|
|
11
|
+
const helper_1 = require("../common/helper");
|
|
12
|
+
const polling = {
|
|
13
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
14
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, lastFetchEpochMS }) {
|
|
15
|
+
var _b;
|
|
16
|
+
const { calendar_id: calendarId, specific_event, event_id, cancellation_reason, } = propsValue;
|
|
17
|
+
if (!calendarId) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
if (specific_event && !event_id) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
let minUpdated;
|
|
24
|
+
if (lastFetchEpochMS === 0) {
|
|
25
|
+
minUpdated = new Date();
|
|
26
|
+
minUpdated.setDate(minUpdated.getDate() - 1);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
minUpdated = new Date(lastFetchEpochMS);
|
|
30
|
+
}
|
|
31
|
+
let events = [];
|
|
32
|
+
if (specific_event && event_id) {
|
|
33
|
+
const eventRequest = {
|
|
34
|
+
method: pieces_common_2.HttpMethod.GET,
|
|
35
|
+
url: `${common_1.googleCalendarCommon.baseUrl}/calendars/${calendarId}/events/${event_id}`,
|
|
36
|
+
authentication: {
|
|
37
|
+
type: pieces_common_2.AuthenticationType.BEARER_TOKEN,
|
|
38
|
+
token: auth.access_token,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
try {
|
|
42
|
+
const eventResponse = yield pieces_common_2.httpClient.sendRequest(eventRequest);
|
|
43
|
+
const event = eventResponse.body;
|
|
44
|
+
const updatedTime = new Date((_b = event.updated) !== null && _b !== void 0 ? _b : 0).getTime();
|
|
45
|
+
if (updatedTime > lastFetchEpochMS && event.status === 'cancelled') {
|
|
46
|
+
events = [event];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Error fetching specific event:', error);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const allEvents = yield (0, helper_1.getEvents)(calendarId, true, auth, minUpdated);
|
|
56
|
+
events = allEvents.filter((event) => event.status === 'cancelled');
|
|
57
|
+
}
|
|
58
|
+
if (cancellation_reason && cancellation_reason.length > 0) {
|
|
59
|
+
events = events.filter((event) => {
|
|
60
|
+
return cancellation_reason.some((reason) => {
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
switch (reason) {
|
|
63
|
+
case 'deleted':
|
|
64
|
+
return !event.summary || event.summary.includes('Deleted');
|
|
65
|
+
case 'declined':
|
|
66
|
+
return (((_a = event.attendees) === null || _a === void 0 ? void 0 : _a.some((attendee) => attendee.responseStatus === 'declined')) || false);
|
|
67
|
+
case 'rescheduled':
|
|
68
|
+
return (((_b = event.summary) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes('rescheduled')) ||
|
|
69
|
+
((_c = event.description) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes('rescheduled')) ||
|
|
70
|
+
false);
|
|
71
|
+
case 'other':
|
|
72
|
+
return true;
|
|
73
|
+
default:
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return events.map((event) => {
|
|
80
|
+
return {
|
|
81
|
+
epochMilliSeconds: new Date(event.updated).getTime(),
|
|
82
|
+
data: event,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
exports.eventCancelled = (0, pieces_framework_1.createTrigger)({
|
|
88
|
+
auth: __1.googleCalendarAuth,
|
|
89
|
+
name: 'event_cancelled',
|
|
90
|
+
displayName: 'Event Cancelled',
|
|
91
|
+
description: 'Fires when an event is canceled or deleted.',
|
|
92
|
+
props: {
|
|
93
|
+
calendar_id: common_1.googleCalendarCommon.calendarDropdown('writer'),
|
|
94
|
+
specific_event: pieces_framework_1.Property.Checkbox({
|
|
95
|
+
displayName: 'Target Specific Event',
|
|
96
|
+
description: 'Enable to monitor a specific event instead of all events in the calendar.',
|
|
97
|
+
required: false,
|
|
98
|
+
defaultValue: false,
|
|
99
|
+
}),
|
|
100
|
+
event_id: common_1.googleCalendarCommon.eventDropdown(false),
|
|
101
|
+
cancellation_reason: pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
102
|
+
displayName: 'Cancellation Reasons',
|
|
103
|
+
description: 'Filter by specific types of cancellations (optional)',
|
|
104
|
+
required: false,
|
|
105
|
+
options: {
|
|
106
|
+
options: [
|
|
107
|
+
{ label: 'Event Deleted', value: 'deleted' },
|
|
108
|
+
{ label: 'Attendee Declined', value: 'declined' },
|
|
109
|
+
{ label: 'Event Rescheduled', value: 'rescheduled' },
|
|
110
|
+
{ label: 'Other Cancellations', value: 'other' },
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
type: pieces_framework_2.TriggerStrategy.POLLING,
|
|
116
|
+
sampleData: {
|
|
117
|
+
id: 'abc123def456_cancelled',
|
|
118
|
+
summary: 'Cancelled: Q3 Planning Session',
|
|
119
|
+
status: 'cancelled',
|
|
120
|
+
created: '2025-07-20T10:00:00.000Z',
|
|
121
|
+
updated: '2025-08-14T09:30:00.000Z',
|
|
122
|
+
organizer: { email: 'project.manager@example.com' },
|
|
123
|
+
start: { dateTime: '2025-08-25T10:00:00-07:00' },
|
|
124
|
+
end: { dateTime: '2025-08-25T11:30:00-07:00' },
|
|
125
|
+
},
|
|
126
|
+
onEnable(context) {
|
|
127
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
129
|
+
auth: context.auth,
|
|
130
|
+
store: context.store,
|
|
131
|
+
propsValue: context.propsValue,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
onDisable(context) {
|
|
136
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
138
|
+
auth: context.auth,
|
|
139
|
+
store: context.store,
|
|
140
|
+
propsValue: context.propsValue,
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
run(context) {
|
|
145
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
147
|
+
auth: context.auth,
|
|
148
|
+
store: context.store,
|
|
149
|
+
propsValue: context.propsValue,
|
|
150
|
+
files: context.files,
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
test(context) {
|
|
155
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
157
|
+
auth: context.auth,
|
|
158
|
+
store: context.store,
|
|
159
|
+
propsValue: context.propsValue,
|
|
160
|
+
files: context.files,
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
//# sourceMappingURL=event-cancelled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-cancelled.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/triggers/event-cancelled.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,qEAAiE;AACjE,sCAAiD;AAEjD,8BAA4C;AAC5C,+DAIqC;AACrC,+DAKqC;AACrC,6CAA6C;AAM7C,MAAM,OAAO,GAQT;IACF,QAAQ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AE;gBACvC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const eventEnds: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
6
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
7
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
8
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
9
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
10
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
11
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
12
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
13
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventEnds = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_framework_2 = require("@activepieces/pieces-framework");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const __1 = require("../../");
|
|
9
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
|
+
const pieces_common_2 = require("@activepieces/pieces-common");
|
|
11
|
+
const polling = {
|
|
12
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, lastFetchEpochMS }) {
|
|
14
|
+
var _b, _c, _d, _e, _f, _g;
|
|
15
|
+
if (lastFetchEpochMS === 0) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const { calendar_id: calendarId, specific_event, event_id } = propsValue;
|
|
19
|
+
if (!calendarId) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
if (specific_event && !event_id) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
let events = [];
|
|
26
|
+
if (specific_event && event_id) {
|
|
27
|
+
const eventRequest = {
|
|
28
|
+
method: pieces_common_2.HttpMethod.GET,
|
|
29
|
+
url: `${common_1.googleCalendarCommon.baseUrl}/calendars/${calendarId}/events/${event_id}`,
|
|
30
|
+
authentication: {
|
|
31
|
+
type: pieces_common_2.AuthenticationType.BEARER_TOKEN,
|
|
32
|
+
token: auth.access_token,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
const eventResponse = yield pieces_common_2.httpClient.sendRequest(eventRequest);
|
|
37
|
+
const event = eventResponse.body;
|
|
38
|
+
const endTimeString = (_c = (_b = event.end) === null || _b === void 0 ? void 0 : _b.dateTime) !== null && _c !== void 0 ? _c : (_d = event.end) === null || _d === void 0 ? void 0 : _d.date;
|
|
39
|
+
if (endTimeString) {
|
|
40
|
+
const endTime = new Date(endTimeString).getTime();
|
|
41
|
+
if (endTime > lastFetchEpochMS) {
|
|
42
|
+
events = [event];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('Error fetching specific event:', error);
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const request = {
|
|
53
|
+
method: pieces_common_2.HttpMethod.GET,
|
|
54
|
+
url: `${common_1.googleCalendarCommon.baseUrl}/calendars/${calendarId}/events`,
|
|
55
|
+
authentication: {
|
|
56
|
+
type: pieces_common_2.AuthenticationType.BEARER_TOKEN,
|
|
57
|
+
token: auth.access_token,
|
|
58
|
+
},
|
|
59
|
+
queryParams: {
|
|
60
|
+
singleEvents: 'true',
|
|
61
|
+
orderBy: 'startTime',
|
|
62
|
+
timeMin: new Date(lastFetchEpochMS).toISOString(),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const response = yield pieces_common_2.httpClient.sendRequest(request);
|
|
66
|
+
events = response.body.items;
|
|
67
|
+
}
|
|
68
|
+
const endedEvents = [];
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
for (const event of events) {
|
|
71
|
+
const endTimeString = (_f = (_e = event.end) === null || _e === void 0 ? void 0 : _e.dateTime) !== null && _f !== void 0 ? _f : (_g = event.end) === null || _g === void 0 ? void 0 : _g.date;
|
|
72
|
+
if (!endTimeString)
|
|
73
|
+
continue;
|
|
74
|
+
const endTime = new Date(endTimeString).getTime();
|
|
75
|
+
if (endTime > lastFetchEpochMS && endTime <= now) {
|
|
76
|
+
endedEvents.push({
|
|
77
|
+
epochMilliSeconds: endTime,
|
|
78
|
+
data: event,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return endedEvents;
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
exports.eventEnds = (0, pieces_framework_1.createTrigger)({
|
|
86
|
+
auth: __1.googleCalendarAuth,
|
|
87
|
+
name: 'event_ends',
|
|
88
|
+
displayName: 'Event Ends',
|
|
89
|
+
description: 'Fires when an event ends.',
|
|
90
|
+
props: {
|
|
91
|
+
calendar_id: common_1.googleCalendarCommon.calendarDropdown('writer'),
|
|
92
|
+
specific_event: pieces_framework_1.Property.Checkbox({
|
|
93
|
+
displayName: 'Target Specific Event',
|
|
94
|
+
description: 'Enable to monitor a specific event instead of all events in the calendar.',
|
|
95
|
+
required: false,
|
|
96
|
+
defaultValue: false,
|
|
97
|
+
}),
|
|
98
|
+
event_id: common_1.googleCalendarCommon.eventDropdown(false),
|
|
99
|
+
},
|
|
100
|
+
type: pieces_framework_2.TriggerStrategy.POLLING,
|
|
101
|
+
sampleData: {
|
|
102
|
+
kind: 'calendar#event',
|
|
103
|
+
etag: '"3419997894982000"',
|
|
104
|
+
id: 'sample_event_id_67890',
|
|
105
|
+
status: 'confirmed',
|
|
106
|
+
htmlLink: 'https://www.google.com/calendar/event?eid=c2FtcGxlX2V2ZW50X2lkXzY3ODkw',
|
|
107
|
+
created: '2025-08-14T09:00:00.000Z',
|
|
108
|
+
updated: '2025-08-14T09:00:00.000Z',
|
|
109
|
+
summary: 'Project Deadline',
|
|
110
|
+
creator: { email: 'manager@example.com' },
|
|
111
|
+
organizer: {
|
|
112
|
+
email: 'manager@example.com',
|
|
113
|
+
self: true,
|
|
114
|
+
},
|
|
115
|
+
start: {
|
|
116
|
+
dateTime: '2025-08-14T14:30:00+05:30',
|
|
117
|
+
timeZone: 'Asia/Kolkata',
|
|
118
|
+
},
|
|
119
|
+
end: {
|
|
120
|
+
dateTime: '2025-08-14T15:30:00+05:30',
|
|
121
|
+
timeZone: 'Asia/Kolkata',
|
|
122
|
+
},
|
|
123
|
+
iCalUID: 'sample_event_id_67890@google.com',
|
|
124
|
+
sequence: 0,
|
|
125
|
+
reminders: { useDefault: true },
|
|
126
|
+
eventType: 'default',
|
|
127
|
+
},
|
|
128
|
+
onEnable(context) {
|
|
129
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
131
|
+
auth: context.auth,
|
|
132
|
+
store: context.store,
|
|
133
|
+
propsValue: context.propsValue,
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
onDisable(context) {
|
|
138
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
140
|
+
auth: context.auth,
|
|
141
|
+
store: context.store,
|
|
142
|
+
propsValue: context.propsValue,
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
run(context) {
|
|
147
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
149
|
+
auth: context.auth,
|
|
150
|
+
store: context.store,
|
|
151
|
+
propsValue: context.propsValue,
|
|
152
|
+
files: context.files,
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
test(context) {
|
|
157
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
159
|
+
auth: context.auth,
|
|
160
|
+
store: context.store,
|
|
161
|
+
propsValue: context.propsValue,
|
|
162
|
+
files: context.files,
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
//# sourceMappingURL=event-ends.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-ends.js","sourceRoot":"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ategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const eventStartTimeBefore: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
5
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
6
|
+
time_value: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
7
|
+
time_unit: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
9
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
10
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
11
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
12
|
+
time_value: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
13
|
+
time_unit: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
14
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
15
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
16
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
17
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
18
|
+
time_value: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
19
|
+
time_unit: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventStartTimeBefore = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_framework_2 = require("@activepieces/pieces-framework");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const __1 = require("../../");
|
|
9
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
10
|
+
const pieces_common_2 = require("@activepieces/pieces-common");
|
|
11
|
+
const polling = {
|
|
12
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue }) {
|
|
14
|
+
var _b, _c, _d, _e;
|
|
15
|
+
const { calendar_id, specific_event, event_id, time_value, time_unit } = propsValue;
|
|
16
|
+
if (!calendar_id || !time_value || !time_unit) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
if (specific_event && !event_id) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
let offset_ms = time_value * 60 * 1000;
|
|
23
|
+
if (time_unit === 'hours') {
|
|
24
|
+
offset_ms = time_value * 60 * 60 * 1000;
|
|
25
|
+
}
|
|
26
|
+
else if (time_unit === 'days') {
|
|
27
|
+
offset_ms = time_value * 24 * 60 * 60 * 1000;
|
|
28
|
+
}
|
|
29
|
+
const now = Date.now();
|
|
30
|
+
const pollingIntervalMs = 5 * 60 * 1000;
|
|
31
|
+
const timeMin = new Date(now + offset_ms).toISOString();
|
|
32
|
+
const timeMax = new Date(now + offset_ms + pollingIntervalMs).toISOString();
|
|
33
|
+
let events = [];
|
|
34
|
+
if (specific_event && event_id) {
|
|
35
|
+
const eventRequest = {
|
|
36
|
+
method: pieces_common_2.HttpMethod.GET,
|
|
37
|
+
url: `${common_1.googleCalendarCommon.baseUrl}/calendars/${calendar_id}/events/${event_id}`,
|
|
38
|
+
authentication: {
|
|
39
|
+
type: pieces_common_2.AuthenticationType.BEARER_TOKEN,
|
|
40
|
+
token: auth.access_token,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
const eventResponse = yield pieces_common_2.httpClient.sendRequest(eventRequest);
|
|
45
|
+
const event = eventResponse.body;
|
|
46
|
+
// Check if this specific event falls within our time window
|
|
47
|
+
const eventStartTime = new Date((_e = (_c = (_b = event.start) === null || _b === void 0 ? void 0 : _b.dateTime) !== null && _c !== void 0 ? _c : (_d = event.start) === null || _d === void 0 ? void 0 : _d.date) !== null && _e !== void 0 ? _e : 0).getTime();
|
|
48
|
+
const triggerTime = eventStartTime - offset_ms;
|
|
49
|
+
if (triggerTime >= now && triggerTime <= now + pollingIntervalMs) {
|
|
50
|
+
events = [event];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error('Error fetching specific event:', error);
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const request = {
|
|
60
|
+
method: pieces_common_2.HttpMethod.GET,
|
|
61
|
+
url: `${common_1.googleCalendarCommon.baseUrl}/calendars/${calendar_id}/events`,
|
|
62
|
+
authentication: {
|
|
63
|
+
type: pieces_common_2.AuthenticationType.BEARER_TOKEN,
|
|
64
|
+
token: auth.access_token,
|
|
65
|
+
},
|
|
66
|
+
queryParams: {
|
|
67
|
+
singleEvents: 'true',
|
|
68
|
+
orderBy: 'startTime',
|
|
69
|
+
timeMin: timeMin,
|
|
70
|
+
timeMax: timeMax,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const response = yield pieces_common_2.httpClient.sendRequest(request);
|
|
74
|
+
events = response.body.items;
|
|
75
|
+
}
|
|
76
|
+
return events.map((event) => {
|
|
77
|
+
var _a, _b, _c, _d;
|
|
78
|
+
const startTime = new Date((_d = (_b = (_a = event.start) === null || _a === void 0 ? void 0 : _a.dateTime) !== null && _b !== void 0 ? _b : (_c = event.start) === null || _c === void 0 ? void 0 : _c.date) !== null && _d !== void 0 ? _d : 0).getTime();
|
|
79
|
+
const triggerTime = startTime - offset_ms;
|
|
80
|
+
return {
|
|
81
|
+
epochMilliSeconds: triggerTime,
|
|
82
|
+
data: event,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
exports.eventStartTimeBefore = (0, pieces_framework_1.createTrigger)({
|
|
88
|
+
auth: __1.googleCalendarAuth,
|
|
89
|
+
name: 'event_starts_in',
|
|
90
|
+
displayName: 'Event Start (Time Before)',
|
|
91
|
+
description: 'Fires at a specified amount of time before an event starts (e.g., a reminder).',
|
|
92
|
+
props: {
|
|
93
|
+
calendar_id: common_1.googleCalendarCommon.calendarDropdown('writer'),
|
|
94
|
+
specific_event: pieces_framework_1.Property.Checkbox({
|
|
95
|
+
displayName: 'Target Specific Event',
|
|
96
|
+
description: 'Enable to monitor a specific event instead of all events in the calendar.',
|
|
97
|
+
required: false,
|
|
98
|
+
defaultValue: false,
|
|
99
|
+
}),
|
|
100
|
+
event_id: common_1.googleCalendarCommon.eventDropdown(false),
|
|
101
|
+
time_value: pieces_framework_1.Property.Number({
|
|
102
|
+
displayName: 'Time Before',
|
|
103
|
+
description: 'The amount of time before the event starts.',
|
|
104
|
+
required: true,
|
|
105
|
+
defaultValue: 15,
|
|
106
|
+
}),
|
|
107
|
+
time_unit: pieces_framework_1.Property.StaticDropdown({
|
|
108
|
+
displayName: 'Time Unit',
|
|
109
|
+
required: true,
|
|
110
|
+
options: {
|
|
111
|
+
options: [
|
|
112
|
+
{ label: 'Minutes', value: 'minutes' },
|
|
113
|
+
{ label: 'Hours', value: 'hours' },
|
|
114
|
+
{ label: 'Days', value: 'days' },
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
defaultValue: 'minutes',
|
|
118
|
+
}),
|
|
119
|
+
},
|
|
120
|
+
type: pieces_framework_2.TriggerStrategy.POLLING,
|
|
121
|
+
sampleData: {},
|
|
122
|
+
onEnable(context) {
|
|
123
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
125
|
+
auth: context.auth,
|
|
126
|
+
store: context.store,
|
|
127
|
+
propsValue: context.propsValue,
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
onDisable(context) {
|
|
132
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
134
|
+
auth: context.auth,
|
|
135
|
+
store: context.store,
|
|
136
|
+
propsValue: context.propsValue,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
run(context) {
|
|
141
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
143
|
+
auth: context.auth,
|
|
144
|
+
store: context.store,
|
|
145
|
+
propsValue: context.propsValue,
|
|
146
|
+
files: context.files,
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
test(context) {
|
|
151
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
153
|
+
auth: context.auth,
|
|
154
|
+
store: context.store,
|
|
155
|
+
propsValue: context.propsValue,
|
|
156
|
+
files: context.files,
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
//# sourceMappingURL=event-start-time-before.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-start-time-before.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/triggers/event-start-time-before.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,qEAAiE;AACjE,sCAAiD;AAEjD,8BAA4C;AAC5C,+DAIqC;AACrC,+DAKqC;AAMrC,MAAM,OAAO,GAST;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA6B,EAAE,oDAAxB,EAAE,IAAI,EAAE,UAAU,EAAE;;QAChC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,GACpE,UAAU,CAAC;QAEb,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,cAAc,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,SAAS,GAAG,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;QACvC,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;YAC1B,SAAS,GAAG,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC1C,CAAC;aAAM,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YAChC,SAAS,GAAG,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAC/C,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEvB,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAExC,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QACxD,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,GAA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OAAO,CAAC,KAAK;aACrB,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,IAAI,CAAC,OAAO;;YAChB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE;gBACvC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newCalendar: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
access_role_filter: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
4
|
+
calendar_name_filter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
exclude_shared: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
7
|
+
access_role_filter: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
8
|
+
calendar_name_filter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
exclude_shared: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
11
|
+
access_role_filter: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
12
|
+
calendar_name_filter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
exclude_shared: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
14
|
+
}>;
|