@activepieces/piece-google-calendar 0.5.7 → 0.6.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 +11 -11
- 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
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-google-calendar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@ai-sdk/anthropic": "
|
|
6
|
-
"@ai-sdk/google": "
|
|
7
|
-
"@ai-sdk/openai": "
|
|
8
|
-
"@ai-sdk/
|
|
5
|
+
"@ai-sdk/anthropic": "2.0.3",
|
|
6
|
+
"@ai-sdk/google": "2.0.6",
|
|
7
|
+
"@ai-sdk/openai": "2.0.12",
|
|
8
|
+
"@ai-sdk/provider": "2.0.0",
|
|
9
|
+
"@ai-sdk/replicate": "1.0.3",
|
|
9
10
|
"@sinclair/typebox": "0.34.11",
|
|
10
|
-
"ai": "
|
|
11
|
+
"ai": "5.0.12",
|
|
11
12
|
"axios": "1.8.3",
|
|
12
13
|
"axios-retry": "4.4.1",
|
|
13
14
|
"dayjs": "1.11.9",
|
|
@@ -19,9 +20,9 @@
|
|
|
19
20
|
"nanoid": "3.3.8",
|
|
20
21
|
"semver": "7.6.0",
|
|
21
22
|
"zod": "3.25.76",
|
|
22
|
-
"@activepieces/pieces-common": "0.6.
|
|
23
|
-
"@activepieces/pieces-framework": "0.
|
|
24
|
-
"@activepieces/shared": "0.
|
|
23
|
+
"@activepieces/pieces-common": "0.6.4",
|
|
24
|
+
"@activepieces/pieces-framework": "0.18.3",
|
|
25
|
+
"@activepieces/shared": "0.18.1",
|
|
25
26
|
"tslib": "2.8.1"
|
|
26
27
|
},
|
|
27
28
|
"overrides": {
|
|
@@ -30,8 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"vite": {
|
|
32
33
|
"rollup": "npm:@rollup/wasm-node"
|
|
33
|
-
}
|
|
34
|
-
"stylus": "0.0.1-security"
|
|
34
|
+
}
|
|
35
35
|
},
|
|
36
36
|
"resolutions": {
|
|
37
37
|
"rollup": "npm:@rollup/wasm-node"
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,14 @@ const update_event_action_1 = require("./lib/actions/update-event.action");
|
|
|
13
13
|
const common_1 = require("./lib/common");
|
|
14
14
|
const calendar_event_1 = require("./lib/triggers/calendar-event");
|
|
15
15
|
const add_attendees_action_1 = require("./lib/actions/add-attendees.action");
|
|
16
|
+
const find_busy_free_periods_1 = require("./lib/actions/find-busy-free-periods");
|
|
17
|
+
const get_event_by_id_1 = require("./lib/actions/get-event-by-id");
|
|
18
|
+
const new_event_1 = require("./lib/triggers/new-event");
|
|
19
|
+
const event_ends_1 = require("./lib/triggers/event-ends");
|
|
20
|
+
const event_start_time_before_1 = require("./lib/triggers/event-start-time-before");
|
|
21
|
+
const new_event_matching_search_1 = require("./lib/triggers/new-event-matching-search");
|
|
22
|
+
const event_cancelled_1 = require("./lib/triggers/event-cancelled");
|
|
23
|
+
const new_calendar_1 = require("./lib/triggers/new-calendar");
|
|
16
24
|
exports.googleCalendarAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
17
25
|
description: '',
|
|
18
26
|
authUrl: 'https://accounts.google.com/o/oauth2/auth',
|
|
@@ -49,6 +57,8 @@ exports.googleCalendar = (0, pieces_framework_1.createPiece)({
|
|
|
49
57
|
get_events_1.getEvents,
|
|
50
58
|
update_event_action_1.updateEventAction,
|
|
51
59
|
delete_event_action_1.deleteEventAction,
|
|
60
|
+
find_busy_free_periods_1.findFreeBusy,
|
|
61
|
+
get_event_by_id_1.getEventById,
|
|
52
62
|
(0, pieces_common_1.createCustomApiCallAction)({
|
|
53
63
|
auth: exports.googleCalendarAuth,
|
|
54
64
|
baseUrl() {
|
|
@@ -61,6 +71,13 @@ exports.googleCalendar = (0, pieces_framework_1.createPiece)({
|
|
|
61
71
|
}),
|
|
62
72
|
}),
|
|
63
73
|
],
|
|
64
|
-
triggers: [calendar_event_1.calendarEventChanged
|
|
74
|
+
triggers: [calendar_event_1.calendarEventChanged,
|
|
75
|
+
new_event_1.newEvent,
|
|
76
|
+
event_ends_1.eventEnds,
|
|
77
|
+
event_start_time_before_1.eventStartTimeBefore,
|
|
78
|
+
new_event_matching_search_1.newEventMatchingSearch,
|
|
79
|
+
event_cancelled_1.eventCancelled,
|
|
80
|
+
new_calendar_1.newCalendar
|
|
81
|
+
],
|
|
65
82
|
});
|
|
66
83
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/google-calendar/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAIwC;AACxC,iDAAqD;AACrD,6DAAyD;AACzD,yEAA4E;AAC5E,2EAAsE;AACtE,yDAAqD;AACrD,2EAAsE;AACtE,yCAAoD;AACpD,kEAAqE;AACrE,6EAA+E;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/google-calendar/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAIwC;AACxC,iDAAqD;AACrD,6DAAyD;AACzD,yEAA4E;AAC5E,2EAAsE;AACtE,yDAAqD;AACrD,2EAAsE;AACtE,yCAAoD;AACpD,kEAAqE;AACrE,6EAA+E;AAC/E,iFAAoE;AACpE,mEAA6D;AAC7D,wDAAoD;AACpD,0DAAsD;AACtD,oFAA8E;AAC9E,wFAAkF;AAClF,oEAAgE;AAChE,8DAA0D;AAE7C,QAAA,kBAAkB,GAAG,4BAAS,CAAC,MAAM,CAAC;IACjD,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,2CAA2C;IACpD,QAAQ,EAAE,qCAAqC;IAC/C,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,IAAI;IACV,KAAK,EAAE;QACL,iDAAiD;QACjD,mDAAmD;KACpD;CACF,CAAC,CAAC;AAEU,QAAA,cAAc,GAAG,IAAA,8BAAW,EAAC;IACxC,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,yDAAyD;IAClE,UAAU,EAAE,CAAC,sBAAa,CAAC,YAAY,CAAC;IACxC,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,oCAAoC;IAEjD,OAAO,EAAE;QACP,aAAa;QACb,kBAAkB;QAClB,UAAU;QACV,cAAc;QACd,YAAY;QACZ,WAAW;QACX,eAAe;QACf,UAAU;QACV,SAAS;KACV;IACD,IAAI,EAAE,0BAAkB;IACxB,OAAO,EAAE;QACP,gDAAyB;QACzB,6CAAwB;QACxB,0BAAW;QACX,sBAAS;QACT,uCAAiB;QACjB,uCAAiB;QACjB,qCAAY;QACZ,8BAAY;QACZ,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,0BAAkB;YACxB,OAAO;gBACL,OAAO,6BAAoB,CAAC,OAAO,CAAC;YACtC,CAAC;YACD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,OAAO;oBACL,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;iBACtE,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,qCAAoB;QAC7B,oBAAQ;QACR,sBAAS;QACT,8CAAoB;QACpB,kDAAsB;QACtB,gCAAc;QACd,0BAAW;KACZ;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const findFreeBusy: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
calendar_ids: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, true>;
|
|
3
|
+
start_date: import("@activepieces/pieces-framework").DateTimeProperty<true>;
|
|
4
|
+
end_date: import("@activepieces/pieces-framework").DateTimeProperty<true>;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFreeBusy = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const __1 = require("../../");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
const helper_1 = require("../common/helper");
|
|
10
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
11
|
+
exports.findFreeBusy = (0, pieces_framework_1.createAction)({
|
|
12
|
+
auth: __1.googleCalendarAuth,
|
|
13
|
+
name: 'google_calendar_find_busy_free_periods',
|
|
14
|
+
displayName: 'Find Busy/Free Periods in Calendar',
|
|
15
|
+
description: 'Finds free/busy calendar details from Google Calendar.',
|
|
16
|
+
props: {
|
|
17
|
+
calendar_ids: pieces_framework_1.Property.MultiSelectDropdown({
|
|
18
|
+
displayName: 'Calendars',
|
|
19
|
+
description: 'Select the calendars to check for busy periods.',
|
|
20
|
+
required: true,
|
|
21
|
+
refreshers: [],
|
|
22
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
23
|
+
if (!auth) {
|
|
24
|
+
return {
|
|
25
|
+
disabled: true,
|
|
26
|
+
placeholder: 'Connect your account first',
|
|
27
|
+
options: [],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const authProp = auth;
|
|
31
|
+
const calendars = yield (0, helper_1.getCalendars)(authProp);
|
|
32
|
+
return {
|
|
33
|
+
disabled: false,
|
|
34
|
+
options: calendars.map((calendar) => {
|
|
35
|
+
return {
|
|
36
|
+
label: calendar.summary,
|
|
37
|
+
value: calendar.id,
|
|
38
|
+
};
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}),
|
|
42
|
+
}),
|
|
43
|
+
start_date: pieces_framework_1.Property.DateTime({
|
|
44
|
+
displayName: 'Start Time',
|
|
45
|
+
description: 'The start of the time range to check.',
|
|
46
|
+
required: true,
|
|
47
|
+
}),
|
|
48
|
+
end_date: pieces_framework_1.Property.DateTime({
|
|
49
|
+
displayName: 'End Time',
|
|
50
|
+
description: 'The end of the time range to check.',
|
|
51
|
+
required: true,
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
run(context) {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const { calendar_ids, start_date, end_date } = context.propsValue;
|
|
57
|
+
const { access_token } = context.auth;
|
|
58
|
+
const requestBody = {
|
|
59
|
+
timeMin: (0, dayjs_1.default)(start_date).toISOString(),
|
|
60
|
+
timeMax: (0, dayjs_1.default)(end_date).toISOString(),
|
|
61
|
+
items: calendar_ids.map((id) => ({ id })),
|
|
62
|
+
};
|
|
63
|
+
const request = {
|
|
64
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
65
|
+
url: `${common_1.googleCalendarCommon.baseUrl}/freeBusy`,
|
|
66
|
+
body: requestBody,
|
|
67
|
+
authentication: {
|
|
68
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
69
|
+
token: access_token,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
73
|
+
return response.body;
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=find-busy-free-periods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-busy-free-periods.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/actions/find-busy-free-periods.ts"],"names":[],"mappings":";;;;AAAA,qEAA6F;AAC7F,+DAAsG;AACtG,8BAA4C;AAC5C,sCAAiD;AACjD,6CAAgD;AAChD,0DAA0B;AAqBb,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,sBAAkB;IACxB,IAAI,EAAE,wCAAwC;IAC9C,WAAW,EAAE,oCAAoC;IACjD,WAAW,EAAE,wDAAwD;IACrE,KAAK,EAAE;QACL,YAAY,EAAE,2BAAQ,CAAC,mBAAmB,CAAC;YACzC,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,iDAAiD;YAC9D,QAAQ,EAAE,IAAI;YACd,UAAU,E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GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;aAC1C,CAAC;YAEF,MAAM,OAAO,GAAgB;gBAC3B,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,6BAAoB,CAAC,OAAO,WAAW;gBAC/C,IAAI,EAAE,WAAW;gBACjB,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,YAAY;iBACpB;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAmB,OAAO,CAAC,CAAC;YAGzE,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getEventById: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
3
|
+
event_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
max_attendees: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
5
|
+
time_zone: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEventById = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const __1 = require("../../");
|
|
9
|
+
exports.getEventById = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: __1.googleCalendarAuth,
|
|
11
|
+
name: 'google_calendar_get_event_by_id',
|
|
12
|
+
displayName: 'Get Event by ID',
|
|
13
|
+
description: 'Fetch event details by its unique ID from Google Calendar.',
|
|
14
|
+
props: {
|
|
15
|
+
calendar_id: common_1.googleCalendarCommon.calendarDropdown(),
|
|
16
|
+
event_id: pieces_framework_1.Property.ShortText({
|
|
17
|
+
displayName: 'Event ID',
|
|
18
|
+
description: 'The unique ID of the event (e.g., "abc123def456"). You can find this in the event URL or from other calendar actions.',
|
|
19
|
+
required: true,
|
|
20
|
+
}),
|
|
21
|
+
max_attendees: pieces_framework_1.Property.Number({
|
|
22
|
+
displayName: 'Max Attendees',
|
|
23
|
+
description: 'Maximum number of attendees to include in the response. If there are more attendees, only the participant is returned.',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
time_zone: pieces_framework_1.Property.ShortText({
|
|
27
|
+
displayName: 'Time Zone',
|
|
28
|
+
description: 'Time zone for the response (e.g., "America/New_York", "Europe/London"). Defaults to the calendar\'s time zone if not specified.',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
run(context) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
const { calendar_id: calendarId, event_id: eventId, max_attendees: maxAttendees, time_zone: timeZone, } = context.propsValue;
|
|
36
|
+
const { access_token: token } = context.auth;
|
|
37
|
+
if (!calendarId ||
|
|
38
|
+
typeof calendarId !== 'string' ||
|
|
39
|
+
calendarId.trim().length === 0) {
|
|
40
|
+
throw new Error('Calendar ID is required');
|
|
41
|
+
}
|
|
42
|
+
if (!eventId ||
|
|
43
|
+
typeof eventId !== 'string' ||
|
|
44
|
+
eventId.trim().length === 0) {
|
|
45
|
+
throw new Error('Event ID cannot be empty');
|
|
46
|
+
}
|
|
47
|
+
if (eventId.length < 5 || eventId.length > 1024) {
|
|
48
|
+
throw new Error('Event ID must be between 5 and 1024 characters');
|
|
49
|
+
}
|
|
50
|
+
const queryParams = {};
|
|
51
|
+
if (maxAttendees !== undefined && maxAttendees > 0) {
|
|
52
|
+
queryParams.maxAttendees = maxAttendees.toString();
|
|
53
|
+
}
|
|
54
|
+
if (timeZone &&
|
|
55
|
+
typeof timeZone === 'string' &&
|
|
56
|
+
timeZone.trim().length > 0) {
|
|
57
|
+
queryParams.timeZone = timeZone.trim();
|
|
58
|
+
}
|
|
59
|
+
const url = `${common_1.googleCalendarCommon.baseUrl}/calendars/${encodeURIComponent(calendarId.trim())}/events/${encodeURIComponent(eventId.trim())}`;
|
|
60
|
+
const request = {
|
|
61
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
62
|
+
url: url,
|
|
63
|
+
queryParams: queryParams,
|
|
64
|
+
authentication: {
|
|
65
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
66
|
+
token: token,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
71
|
+
return response.body;
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
75
|
+
throw new Error(`Event with ID "${eventId}" not found in calendar "${calendarId}". Please verify the event ID and calendar selection.`);
|
|
76
|
+
}
|
|
77
|
+
else if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 403) {
|
|
78
|
+
throw new Error(`Access denied to event "${eventId}" in calendar "${calendarId}". Please check your permissions.`);
|
|
79
|
+
}
|
|
80
|
+
else if (((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) === 400) {
|
|
81
|
+
throw new Error(`Invalid request parameters. Please check the event ID format and other parameters.`);
|
|
82
|
+
}
|
|
83
|
+
else if (((_d = error.response) === null || _d === void 0 ? void 0 : _d.status) === 401) {
|
|
84
|
+
throw new Error('Authentication failed. Please reconnect your Google Calendar account.');
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new Error(`Failed to fetch event: ${error.message || 'Unknown error occurred'}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=get-event-by-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-event-by-id.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/actions/get-event-by-id.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAKqC;AACrC,sCAAiD;AACjD,8BAA4C;AAG/B,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,sBAAkB;IACxB,IAAI,EAAE,iCAAiC;IACvC,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,4DAA4D;IACzE,KAAK,EAAE;QACL,WAAW,EAAE,6BAAoB,CAAC,gBAAgB,EAAE;QACpD,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EACT,uHAAuH;YACzH,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC7B,WAAW,EAAE,eAAe;YAC5B,WAAW,EACT,wHAAwH;YAC1H,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,WAAW,EACT,iIAAiI;YACnI,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,EACJ,WAAW,EAAE,UAAU,EACvB,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,YAAY,EAC3B,SAAS,EAAE,QAAQ,GACpB,GAAG,OAAO,CAAC,UAAU,CAAC;YACvB,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IA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B,CAAC,YAAY;oBACrC,KAAK,EAAE,KAAK;iBACb;aACF,CAAC;YAEF,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAC3C,OAAO,CACR,CAAC;gBACF,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CACb,kBAAkB,OAAO,4BAA4B,UAAU,uDAAuD,CACvH,CAAC;gBACJ,CAAC;qBAAM,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;oBAC1C,MAAM,IAAI,KAAK,CACb,2BAA2B,OAAO,kBAAkB,UAAU,mCAAmC,CAClG,CAAC;gBACJ,CAAC;qBAAM,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;oBAC1C,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;gBACJ,CAAC;qBAAM,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;oBAC1C,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CACb,0BAA0B,KAAK,CAAC,OAAO,IAAI,wBAAwB,EAAE,CACtE,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -6,3 +6,7 @@ export declare function getCalendars(authProp: OAuth2PropertyValue, minAccessRol
|
|
|
6
6
|
export declare function getColors(authProp: OAuth2PropertyValue): Promise<GetColorsResponse>;
|
|
7
7
|
export declare function getEvents(calendarId: string, expandRecurringEvent: boolean, authProp: OAuth2PropertyValue, minUpdated?: Date): Promise<GoogleCalendarEvent[]>;
|
|
8
8
|
export declare function getLatestEvent(calendarId: string, authProp: OAuth2PropertyValue): Promise<GoogleCalendarEvent>;
|
|
9
|
+
export declare function getEventsForDropdown(authProp: OAuth2PropertyValue, calendarId?: string, maxResults?: number): Promise<{
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[]>;
|
package/src/lib/common/helper.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.getCalendars = getCalendars;
|
|
|
6
6
|
exports.getColors = getColors;
|
|
7
7
|
exports.getEvents = getEvents;
|
|
8
8
|
exports.getLatestEvent = getLatestEvent;
|
|
9
|
+
exports.getEventsForDropdown = getEventsForDropdown;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
10
11
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
11
12
|
const crypto_1 = require("crypto");
|
|
@@ -126,4 +127,65 @@ function getLatestEvent(calendarId, authProp) {
|
|
|
126
127
|
return lastUpdatedEvent;
|
|
127
128
|
});
|
|
128
129
|
}
|
|
130
|
+
function getEventsForDropdown(authProp_1, calendarId_1) {
|
|
131
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (authProp, calendarId, maxResults = 50) {
|
|
132
|
+
if (!calendarId) {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const now = new Date();
|
|
137
|
+
const futureDate = new Date();
|
|
138
|
+
futureDate.setDate(now.getDate() + 30);
|
|
139
|
+
const queryParams = {
|
|
140
|
+
singleEvents: 'true',
|
|
141
|
+
orderBy: 'startTime',
|
|
142
|
+
timeMin: now.toISOString(),
|
|
143
|
+
timeMax: futureDate.toISOString(),
|
|
144
|
+
maxResults: maxResults.toString(),
|
|
145
|
+
showDeleted: 'false',
|
|
146
|
+
};
|
|
147
|
+
const request = {
|
|
148
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
149
|
+
url: `${_1.googleCalendarCommon.baseUrl}/calendars/${encodeURIComponent(calendarId)}/events`,
|
|
150
|
+
queryParams: queryParams,
|
|
151
|
+
authentication: {
|
|
152
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
153
|
+
token: authProp.access_token,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
157
|
+
if (!response.body.items || response.body.items.length === 0) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
return response.body.items
|
|
161
|
+
.map((event) => {
|
|
162
|
+
var _a, _b, _c;
|
|
163
|
+
const startTime = ((_a = event.start) === null || _a === void 0 ? void 0 : _a.dateTime) || ((_b = event.start) === null || _b === void 0 ? void 0 : _b.date) || '';
|
|
164
|
+
const startDate = startTime
|
|
165
|
+
? new Date(startTime).toLocaleDateString()
|
|
166
|
+
: '';
|
|
167
|
+
const startTimeFormatted = startTime
|
|
168
|
+
? new Date(startTime).toLocaleTimeString()
|
|
169
|
+
: '';
|
|
170
|
+
let label = event.summary || 'Untitled Event';
|
|
171
|
+
if (startDate) {
|
|
172
|
+
label += ` (${startDate}`;
|
|
173
|
+
if ((_c = event.start) === null || _c === void 0 ? void 0 : _c.dateTime) {
|
|
174
|
+
label += ` at ${startTimeFormatted}`;
|
|
175
|
+
}
|
|
176
|
+
label += ')';
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
label: label,
|
|
180
|
+
value: event.id || '',
|
|
181
|
+
};
|
|
182
|
+
})
|
|
183
|
+
.filter((item) => item.value !== '');
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
console.error('Error fetching events for dropdown:', error);
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
129
191
|
//# sourceMappingURL=helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/common/helper.ts"],"names":[],"mappings":";;AAmBA,wCAiBC;AAED,gCAsBC;AAED,oCAsBC;AAED,8BAaC;AAED,8BA2CC;AAED,wCAOC;;
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/common/helper.ts"],"names":[],"mappings":";;AAmBA,wCAiBC;AAED,gCAsBC;AAED,oCAsBC;AAED,8BAaC;AAED,8BA2CC;AAED,wCAOC;AAED,oDAwEC;;AAlOD,+DAKqC;AACrC,mCAAoC;AACpC,wBAAyC;AACzC,mCAQiB;AAEjB,SAAsB,cAAc,CAClC,IAAyB,EACzB,QAA6B;;QAE7B,MAAM,OAAO,GAAgB;YAC3B,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,GAAG,uBAAoB,CAAC,OAAO,gBAAgB;YACpD,IAAI,EAAE;gBACJ,EAAE,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,EAAE;gBACZ,UAAU,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU;aAC7B;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;gBACrC,KAAK,EAAE,QAAQ,CAAC,YAAY;aAC7B;SACF,CAAC;QACF,MAAM,0BAAU,CAAC,WAAW,CAAM,OAAO,CAAC,CAAC;IAC7C,CAAC;CAAA;AAED,SAAsB,UAAU,CAC9B,UAAkB,EAClB,UAAkB,EAClB,QAA6B;;QAE7B,MAAM,OAAO,GAAgB;YAC3B,MAAM,EAAE,0BAAU,CAAC,IAAI;YACvB,GAAG,EAAE,GAAG,uBAAoB,CAAC,OAAO,cAAc,UAAU,eAAe;YAC3E,IAAI,EAAE;gBACJ,EAAE,EAAE,IAAA,mBAAU,GAAE;gBAChB,IAAI,EAAE,uBAAe,CAAC,OAAO;gBAC7B,OAAO,EAAE,UAAU;aACpB;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;gBACrC,KAAK,EAAE,Q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f,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAC5D,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const googleCalendarCommon: {
|
|
2
2
|
baseUrl: string;
|
|
3
3
|
calendarDropdown: (minAccessRole?: "writer") => import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
eventDropdown: (required?: boolean) => import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
5
|
colorId: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
|
|
5
6
|
};
|
package/src/lib/common/index.js
CHANGED
|
@@ -33,6 +33,35 @@ exports.googleCalendarCommon = {
|
|
|
33
33
|
}),
|
|
34
34
|
});
|
|
35
35
|
},
|
|
36
|
+
eventDropdown: (required = false) => {
|
|
37
|
+
return pieces_framework_1.Property.Dropdown({
|
|
38
|
+
displayName: 'Event',
|
|
39
|
+
refreshers: ['calendar_id'],
|
|
40
|
+
required: required,
|
|
41
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, calendar_id }) {
|
|
42
|
+
if (!auth) {
|
|
43
|
+
return {
|
|
44
|
+
disabled: true,
|
|
45
|
+
placeholder: 'Please connect your account first',
|
|
46
|
+
options: [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!calendar_id) {
|
|
50
|
+
return {
|
|
51
|
+
disabled: true,
|
|
52
|
+
placeholder: 'Please select a calendar first',
|
|
53
|
+
options: [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const authProp = auth;
|
|
57
|
+
const events = yield (0, helper_1.getEventsForDropdown)(authProp, calendar_id);
|
|
58
|
+
return {
|
|
59
|
+
disabled: false,
|
|
60
|
+
options: events,
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
},
|
|
36
65
|
colorId: pieces_framework_1.Property.Dropdown({
|
|
37
66
|
displayName: 'Color',
|
|
38
67
|
refreshers: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA+E;AAC/E,qCAAyE;AAE5D,QAAA,oBAAoB,GAAG;IAClC,OAAO,EAAE,wCAAwC;IACjD,gBAAgB,EAAE,CAAC,aAAwB,EAAE,EAAE;QAC7C,OAAO,2BAAQ,CAAC,QAAQ,CAAS;YAC/B,WAAW,EAAE,UAAU;YACvB,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACtB,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,mCAAmC;wBAChD,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBACD,MAAM,QAAQ,GAAG,IAA2B,CAAC;gBAC7C,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAY,EAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;gBAC9D,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;wBAClC,OAAO;4BACL,KAAK,EAAE,QAAQ,CAAC,OAAO;4BACvB,KAAK,EAAE,QAAQ,CAAC,EAAE;yBACnB,CAAC;oBACJ,CAAC,CAAC;iBACH,CAAC;YACJ,CAAC,CAAA;SACF,CAAC,CAAC;IACL,CAAC;IACD,aA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C,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;oBAC3D,OAAO;wBACL,KAAK,EAAE,KAAK,CAAC,UAAU;wBACvB,KAAK,EAAE,GAAG;qBACX,CAAC;gBACJ,CAAC,CAAC;aACH,CAAC;QACJ,CAAC,CAAA;KACF,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const eventCancelled: 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
|
+
cancellation_reason: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
7
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
8
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
9
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
11
|
+
cancellation_reason: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
12
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
13
|
+
calendar_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
14
|
+
specific_event: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
15
|
+
event_id: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
16
|
+
cancellation_reason: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
|
|
17
|
+
}>;
|
|
@@ -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
|