@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.
Files changed (34) hide show
  1. package/package.json +9 -8
  2. package/src/i18n/fr.json +17 -17
  3. package/src/index.js +18 -1
  4. package/src/index.js.map +1 -1
  5. package/src/lib/actions/find-busy-free-periods.d.ts +5 -0
  6. package/src/lib/actions/find-busy-free-periods.js +77 -0
  7. package/src/lib/actions/find-busy-free-periods.js.map +1 -0
  8. package/src/lib/actions/get-event-by-id.d.ts +6 -0
  9. package/src/lib/actions/get-event-by-id.js +93 -0
  10. package/src/lib/actions/get-event-by-id.js.map +1 -0
  11. package/src/lib/common/helper.d.ts +4 -0
  12. package/src/lib/common/helper.js +62 -0
  13. package/src/lib/common/helper.js.map +1 -1
  14. package/src/lib/common/index.d.ts +1 -0
  15. package/src/lib/common/index.js +29 -0
  16. package/src/lib/common/index.js.map +1 -1
  17. package/src/lib/triggers/event-cancelled.d.ts +17 -0
  18. package/src/lib/triggers/event-cancelled.js +165 -0
  19. package/src/lib/triggers/event-cancelled.js.map +1 -0
  20. package/src/lib/triggers/event-ends.d.ts +14 -0
  21. package/src/lib/triggers/event-ends.js +167 -0
  22. package/src/lib/triggers/event-ends.js.map +1 -0
  23. package/src/lib/triggers/event-start-time-before.d.ts +20 -0
  24. package/src/lib/triggers/event-start-time-before.js +161 -0
  25. package/src/lib/triggers/event-start-time-before.js.map +1 -0
  26. package/src/lib/triggers/new-calendar.d.ts +14 -0
  27. package/src/lib/triggers/new-calendar.js +151 -0
  28. package/src/lib/triggers/new-calendar.js.map +1 -0
  29. package/src/lib/triggers/new-event-matching-search.d.ts +17 -0
  30. package/src/lib/triggers/new-event-matching-search.js +185 -0
  31. package/src/lib/triggers/new-event-matching-search.js.map +1 -0
  32. package/src/lib/triggers/new-event.d.ts +17 -0
  33. package/src/lib/triggers/new-event.js +161 -0
  34. package/src/lib/triggers/new-event.js.map +1 -0
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newCalendar = 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 __1 = require("../../");
8
+ const pieces_common_1 = require("@activepieces/pieces-common");
9
+ const helper_1 = require("../common/helper");
10
+ const polling = {
11
+ strategy: pieces_common_1.DedupeStrategy.LAST_ITEM,
12
+ items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, store, propsValue }) {
13
+ const { access_role_filter, calendar_name_filter, exclude_shared } = propsValue;
14
+ const currentCalendars = yield (0, helper_1.getCalendars)(auth);
15
+ let filteredCalendars = currentCalendars;
16
+ if (access_role_filter && access_role_filter.length > 0) {
17
+ filteredCalendars = filteredCalendars.filter((cal) => access_role_filter.includes(cal.accessRole));
18
+ }
19
+ if (calendar_name_filter && calendar_name_filter.trim()) {
20
+ const searchTerm = calendar_name_filter.toLowerCase().trim();
21
+ filteredCalendars = filteredCalendars.filter((cal) => {
22
+ var _a, _b;
23
+ return ((_a = cal.summary) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTerm)) ||
24
+ ((_b = cal.description) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTerm));
25
+ });
26
+ }
27
+ if (exclude_shared) {
28
+ filteredCalendars = filteredCalendars.filter((cal) => cal.accessRole === 'owner' || cal.primary);
29
+ }
30
+ const currentCalendarIds = filteredCalendars.map((cal) => cal.id);
31
+ const oldCalendarIds = (yield store.get('calendars')) || [];
32
+ const oldCalendarIdsSet = new Set(oldCalendarIds);
33
+ const newCalendars = filteredCalendars.filter((cal) => !oldCalendarIdsSet.has(cal.id));
34
+ yield store.put('calendars', currentCalendarIds);
35
+ return newCalendars.map((cal) => ({
36
+ id: cal.id,
37
+ data: Object.assign(Object.assign({}, cal), { isOwned: cal.accessRole === 'owner' || cal.primary, isShared: cal.accessRole !== 'owner' && !cal.primary, calendarType: cal.primary
38
+ ? 'primary'
39
+ : cal.accessRole === 'owner'
40
+ ? 'owned'
41
+ : 'shared' }),
42
+ }));
43
+ }),
44
+ };
45
+ exports.newCalendar = (0, pieces_framework_1.createTrigger)({
46
+ auth: __1.googleCalendarAuth,
47
+ name: 'new_calendar',
48
+ displayName: 'New Calendar',
49
+ description: 'Fires when a new calendar is created or becomes accessible.',
50
+ props: {
51
+ access_role_filter: pieces_framework_1.Property.StaticMultiSelectDropdown({
52
+ displayName: 'Access Role Filter',
53
+ description: 'Only trigger for calendars with specific access roles (optional)',
54
+ required: false,
55
+ options: {
56
+ options: [
57
+ { label: 'Owner', value: 'owner' },
58
+ { label: 'Writer', value: 'writer' },
59
+ { label: 'Reader', value: 'reader' },
60
+ { label: 'Free/Busy Reader', value: 'freeBusyReader' },
61
+ ],
62
+ },
63
+ }),
64
+ calendar_name_filter: pieces_framework_1.Property.ShortText({
65
+ displayName: 'Calendar Name Filter',
66
+ description: 'Only trigger for calendars containing this text in name or description (optional)',
67
+ required: false,
68
+ }),
69
+ exclude_shared: pieces_framework_1.Property.Checkbox({
70
+ displayName: 'Exclude Shared Calendars',
71
+ description: 'Only trigger for calendars you own, not shared calendars',
72
+ required: false,
73
+ defaultValue: false,
74
+ }),
75
+ },
76
+ type: pieces_framework_2.TriggerStrategy.POLLING,
77
+ sampleData: {
78
+ id: 'sample_calendar_id@group.calendar.google.com',
79
+ summary: 'New Project Team Calendar',
80
+ description: 'A shared calendar for the new project team.',
81
+ timeZone: 'Asia/Kolkata',
82
+ backgroundColor: '#9fe1e7',
83
+ foregroundColor: '#000000',
84
+ accessRole: 'owner',
85
+ isOwned: true,
86
+ isShared: false,
87
+ calendarType: 'owned',
88
+ primary: false,
89
+ },
90
+ onEnable(context) {
91
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
92
+ const calendars = yield (0, helper_1.getCalendars)(context.auth);
93
+ const { access_role_filter, calendar_name_filter, exclude_shared } = context.propsValue;
94
+ let filteredCalendars = calendars;
95
+ if (access_role_filter && access_role_filter.length > 0) {
96
+ filteredCalendars = filteredCalendars.filter((cal) => access_role_filter.includes(cal.accessRole));
97
+ }
98
+ if (calendar_name_filter && calendar_name_filter.trim()) {
99
+ const searchTerm = calendar_name_filter.toLowerCase().trim();
100
+ filteredCalendars = filteredCalendars.filter((cal) => {
101
+ var _a, _b;
102
+ return ((_a = cal.summary) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTerm)) ||
103
+ ((_b = cal.description) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTerm));
104
+ });
105
+ }
106
+ if (exclude_shared) {
107
+ filteredCalendars = filteredCalendars.filter((cal) => cal.accessRole === 'owner' || cal.primary);
108
+ }
109
+ yield context.store.put('calendars', filteredCalendars.map((cal) => cal.id));
110
+ yield pieces_common_1.pollingHelper.onEnable(polling, {
111
+ auth: context.auth,
112
+ store: context.store,
113
+ propsValue: context.propsValue,
114
+ });
115
+ });
116
+ },
117
+ onDisable(context) {
118
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
119
+ yield pieces_common_1.pollingHelper.onDisable(polling, {
120
+ auth: context.auth,
121
+ store: context.store,
122
+ propsValue: context.propsValue,
123
+ });
124
+ });
125
+ },
126
+ run(context) {
127
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
128
+ return yield pieces_common_1.pollingHelper.poll(polling, {
129
+ auth: context.auth,
130
+ store: context.store,
131
+ propsValue: context.propsValue,
132
+ files: context.files,
133
+ });
134
+ });
135
+ },
136
+ test(context) {
137
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
138
+ const calendars = yield (0, helper_1.getCalendars)(context.auth);
139
+ const recentCalendars = calendars.slice(-1);
140
+ return recentCalendars.map((cal) => ({
141
+ id: cal.id,
142
+ data: Object.assign(Object.assign({}, cal), { isOwned: cal.accessRole === 'owner' || cal.primary, isShared: cal.accessRole !== 'owner' && !cal.primary, calendarType: cal.primary
143
+ ? 'primary'
144
+ : cal.accessRole === 'owner'
145
+ ? 'owned'
146
+ : 'shared' }),
147
+ }));
148
+ });
149
+ },
150
+ });
151
+ //# sourceMappingURL=new-calendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-calendar.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/triggers/new-calendar.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,qEAAiE;AACjE,8BAA4C;AAC5C,+DAIqC;AACrC,6CAAgD;AAGhD,MAAM,OAAO,GAOT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAAoC,EAAE,oDAA/B,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE;QACvC,MAAM,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,GAChE,UAAU,CAAC;QAEb,MAAM,gBAAgB,GAAG,MAAM,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;QAElD,IAAI,iBAAiB,GAAG,gBAAgB,CAAC;QAEzC,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,iBAAiB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CACnD,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAC5C,CAAC;QACJ,CAAC;QAED,IAAI,oBAAoB,IAAI,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC;YACxD,MAAM,UAAU,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;YAC7D,iBAAiB,GAAG,iBAAiB,CAAC,MAAM,CAC1C,CAAC,GAAG,EAAE,EAAE;;gBACN,OAAA,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC;qBAC/C,MAAA,GAAG,CAAC,WAAW,0CAAE,WAAW,GAAG,QAA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AC,UAAU,KAAK,OAAO;4BAC5B,CAAC,CAAC,OAAO;4BACT,CAAC,CAAC,QAAQ,GACb;aACF,CAAC,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newEventMatchingSearch: 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
+ search_term: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
+ event_types: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
6
+ search_fields: 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
+ search_term: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
+ event_types: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
11
+ search_fields: 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
+ search_term: import("@activepieces/pieces-framework").ShortTextProperty<true>;
15
+ event_types: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
16
+ search_fields: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
17
+ }>;
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newEventMatchingSearch = 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
+ const { calendar_id, search_term, event_types, search_fields } = propsValue;
15
+ if (!calendar_id || !search_term) {
16
+ return [];
17
+ }
18
+ let minUpdated;
19
+ if (lastFetchEpochMS === 0) {
20
+ minUpdated = new Date();
21
+ minUpdated.setDate(minUpdated.getDate() - 1);
22
+ }
23
+ else {
24
+ minUpdated = new Date(lastFetchEpochMS);
25
+ }
26
+ const queryParams = {
27
+ singleEvents: 'true',
28
+ orderBy: 'updated',
29
+ updatedMin: minUpdated.toISOString(),
30
+ q: search_term,
31
+ };
32
+ if (event_types && event_types.length > 0) {
33
+ event_types.forEach((type) => {
34
+ if (!queryParams.eventTypes) {
35
+ queryParams.eventTypes = type;
36
+ }
37
+ else {
38
+ queryParams.eventTypes += '&eventTypes=' + type;
39
+ }
40
+ });
41
+ }
42
+ const request = {
43
+ method: pieces_common_2.HttpMethod.GET,
44
+ url: `${common_1.googleCalendarCommon.baseUrl}/calendars/${calendar_id}/events`,
45
+ authentication: {
46
+ type: pieces_common_2.AuthenticationType.BEARER_TOKEN,
47
+ token: auth.access_token,
48
+ },
49
+ queryParams: queryParams,
50
+ };
51
+ const response = yield pieces_common_2.httpClient.sendRequest(request);
52
+ const events = response.body.items;
53
+ const newEvents = events.filter((event) => {
54
+ var _a, _b;
55
+ const created = new Date((_a = event.created) !== null && _a !== void 0 ? _a : 0).getTime();
56
+ const updated = new Date((_b = event.updated) !== null && _b !== void 0 ? _b : 0).getTime();
57
+ const isNewEvent = updated - created < 5000;
58
+ if (!isNewEvent)
59
+ return false;
60
+ if (search_fields && search_fields.length > 0) {
61
+ const searchTermLower = search_term.toLowerCase();
62
+ return search_fields.some((field) => {
63
+ var _a, _b, _c, _d;
64
+ switch (field) {
65
+ case 'summary':
66
+ return (((_a = event.summary) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTermLower)) || false);
67
+ case 'description':
68
+ return (((_b = event.description) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTermLower)) ||
69
+ false);
70
+ case 'location':
71
+ return (((_c = event.location) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(searchTermLower)) || false);
72
+ case 'attendees':
73
+ return (((_d = event.attendees) === null || _d === void 0 ? void 0 : _d.some((attendee) => {
74
+ var _a, _b;
75
+ return ((_a = attendee.email) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTermLower)) ||
76
+ ((_b = attendee.displayName) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTermLower));
77
+ })) || false);
78
+ default:
79
+ return false;
80
+ }
81
+ });
82
+ }
83
+ return true;
84
+ });
85
+ return newEvents.map((event) => {
86
+ return {
87
+ epochMilliSeconds: new Date(event.updated).getTime(),
88
+ data: event,
89
+ };
90
+ });
91
+ }),
92
+ };
93
+ exports.newEventMatchingSearch = (0, pieces_framework_1.createTrigger)({
94
+ auth: __1.googleCalendarAuth,
95
+ name: 'new_event_matching_search',
96
+ displayName: 'New Event Matching Search',
97
+ description: 'Fires when a new event is created that matches a specified search term.',
98
+ props: {
99
+ calendar_id: common_1.googleCalendarCommon.calendarDropdown('writer'),
100
+ search_term: pieces_framework_1.Property.ShortText({
101
+ displayName: 'Search Term',
102
+ description: 'The keyword(s) to search for in new events (searches across title, description, location, and attendees by default).',
103
+ required: true,
104
+ }),
105
+ event_types: pieces_framework_1.Property.StaticMultiSelectDropdown({
106
+ displayName: 'Event Types',
107
+ description: 'Filter by specific event types (optional)',
108
+ required: false,
109
+ options: {
110
+ options: [
111
+ { label: 'Default Events', value: 'default' },
112
+ { label: 'Birthday Events', value: 'birthday' },
113
+ { label: 'Focus Time', value: 'focusTime' },
114
+ { label: 'Out of Office', value: 'outOfOffice' },
115
+ { label: 'Working Location', value: 'workingLocation' },
116
+ { label: 'From Gmail', value: 'fromGmail' },
117
+ ],
118
+ },
119
+ }),
120
+ search_fields: pieces_framework_1.Property.StaticMultiSelectDropdown({
121
+ displayName: 'Search In Fields',
122
+ description: "Specify which fields to search in (leave empty to use Google's default search across all fields)",
123
+ required: false,
124
+ options: {
125
+ options: [
126
+ { label: 'Event Title/Summary', value: 'summary' },
127
+ { label: 'Event Description', value: 'description' },
128
+ { label: 'Event Location', value: 'location' },
129
+ { label: 'Attendee Names/Emails', value: 'attendees' },
130
+ ],
131
+ },
132
+ }),
133
+ },
134
+ type: pieces_framework_2.TriggerStrategy.POLLING,
135
+ sampleData: {
136
+ id: 'abc123def456',
137
+ summary: 'Final Project Review',
138
+ description: 'Review of the Q3 final project deliverables.',
139
+ status: 'confirmed',
140
+ created: '2025-08-14T09:05:00.000Z',
141
+ updated: '2025-08-14T09:05:01.000Z',
142
+ start: { dateTime: '2025-09-01T10:00:00-07:00' },
143
+ end: { dateTime: '2025-09-01T11:30:00-07:00' },
144
+ organizer: { email: 'project.manager@example.com' },
145
+ },
146
+ onEnable(context) {
147
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
148
+ yield pieces_common_1.pollingHelper.onEnable(polling, {
149
+ auth: context.auth,
150
+ store: context.store,
151
+ propsValue: context.propsValue,
152
+ });
153
+ });
154
+ },
155
+ onDisable(context) {
156
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
157
+ yield pieces_common_1.pollingHelper.onDisable(polling, {
158
+ auth: context.auth,
159
+ store: context.store,
160
+ propsValue: context.propsValue,
161
+ });
162
+ });
163
+ },
164
+ run(context) {
165
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
166
+ return yield pieces_common_1.pollingHelper.poll(polling, {
167
+ auth: context.auth,
168
+ store: context.store,
169
+ propsValue: context.propsValue,
170
+ files: context.files,
171
+ });
172
+ });
173
+ },
174
+ test(context) {
175
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
176
+ return yield pieces_common_1.pollingHelper.test(polling, {
177
+ auth: context.auth,
178
+ store: context.store,
179
+ propsValue: context.propsValue,
180
+ files: context.files,
181
+ });
182
+ });
183
+ },
184
+ });
185
+ //# sourceMappingURL=new-event-matching-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-event-matching-search.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/triggers/new-event-matching-search.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,qEAAiE;AACjE,sCAAiD;AAEjD,8BAA4C;AAC5C,+DAIqC;AACrC,+DAKqC;AAMrC,MAAM,OAAO,GAQT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE;QAClD,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,UAAU,CAAC;QAE5E,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,UAAgB,CAAC;QACrB,IAAI,gBAAgB,KAAK,CAAC,EAAE,CAAC;YAC3B,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;YACxB,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC1C,CA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B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,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,17 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newEvent: 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
+ event_types: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
5
+ search_filter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ exclude_all_day: import("@activepieces/pieces-framework").CheckboxProperty<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
+ event_types: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
10
+ search_filter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
11
+ exclude_all_day: import("@activepieces/pieces-framework").CheckboxProperty<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
+ event_types: import("@activepieces/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
15
+ search_filter: import("@activepieces/pieces-framework").ShortTextProperty<false>;
16
+ exclude_all_day: import("@activepieces/pieces-framework").CheckboxProperty<false>;
17
+ }>;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const __1 = require("../../");
7
+ const common_1 = require("../common");
8
+ const helper_1 = require("../common/helper");
9
+ exports.newEvent = (0, pieces_framework_1.createTrigger)({
10
+ auth: __1.googleCalendarAuth,
11
+ name: 'new_event',
12
+ displayName: 'New Event',
13
+ description: 'Fires when a new event is created in a calendar.',
14
+ props: {
15
+ calendar_id: common_1.googleCalendarCommon.calendarDropdown('writer'),
16
+ event_types: pieces_framework_1.Property.StaticMultiSelectDropdown({
17
+ displayName: 'Event Types to Monitor',
18
+ description: 'Filter by specific event types (leave empty to monitor all event types)',
19
+ required: false,
20
+ options: {
21
+ options: [
22
+ { label: 'Default Events', value: 'default' },
23
+ { label: 'Birthday Events', value: 'birthday' },
24
+ { label: 'Focus Time', value: 'focusTime' },
25
+ { label: 'Out of Office', value: 'outOfOffice' },
26
+ { label: 'Working Location', value: 'workingLocation' },
27
+ { label: 'From Gmail', value: 'fromGmail' },
28
+ ],
29
+ },
30
+ }),
31
+ search_filter: pieces_framework_1.Property.ShortText({
32
+ displayName: 'Search Filter',
33
+ description: 'Only trigger for events containing this text in title, description, or location (optional)',
34
+ required: false,
35
+ }),
36
+ exclude_all_day: pieces_framework_1.Property.Checkbox({
37
+ displayName: 'Exclude All-Day Events',
38
+ description: 'Skip triggering for all-day events',
39
+ required: false,
40
+ defaultValue: false,
41
+ }),
42
+ },
43
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
44
+ sampleData: {
45
+ kind: 'calendar#event',
46
+ etag: '"3419997894982000"',
47
+ id: 'sample_event_id_12345',
48
+ status: 'confirmed',
49
+ htmlLink: 'https://www.google.com/calendar/event?eid=c2FtcGxlX2V2ZW50X2lkXzEyMzQ1',
50
+ created: '2025-08-15T11:02:27.000Z',
51
+ updated: '2025-08-15T11:02:27.491Z',
52
+ summary: 'Team Sync',
53
+ creator: { email: 'creator@example.com' },
54
+ organizer: {
55
+ email: 'creator@example.com',
56
+ self: true,
57
+ },
58
+ start: {
59
+ dateTime: '2025-08-18T10:00:00-07:00',
60
+ timeZone: 'America/Los_Angeles',
61
+ },
62
+ end: {
63
+ dateTime: '2025-08-18T11:00:00-07:00',
64
+ timeZone: 'America/Los_Angeles',
65
+ },
66
+ iCalUID: 'sample_event_id_12345@google.com',
67
+ sequence: 0,
68
+ reminders: { useDefault: true },
69
+ eventType: 'default',
70
+ },
71
+ onEnable(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ const calendarId = context.propsValue.calendar_id;
74
+ const auth = context.auth;
75
+ const response = yield (0, helper_1.watchEvent)(calendarId, context.webhookUrl, auth);
76
+ yield context.store.put('google_calendar_watch', response);
77
+ });
78
+ },
79
+ onDisable(context) {
80
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
81
+ const auth = context.auth;
82
+ const watch = yield context.store.get('google_calendar_watch');
83
+ if (watch) {
84
+ yield (0, helper_1.stopWatchEvent)(watch, auth);
85
+ }
86
+ });
87
+ },
88
+ run(context) {
89
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
90
+ var _a, _b;
91
+ const payload = context.payload;
92
+ const headers = payload.headers;
93
+ const { event_types, search_filter, exclude_all_day } = context.propsValue;
94
+ if (headers['x-goog-resource-state'] === 'add') {
95
+ const eventData = payload.body;
96
+ if (event_types && event_types.length > 0) {
97
+ const eventType = eventData.eventType || 'default';
98
+ if (!event_types.includes(eventType)) {
99
+ return [];
100
+ }
101
+ }
102
+ if (search_filter && search_filter.trim()) {
103
+ const searchTerm = search_filter.toLowerCase().trim();
104
+ const summary = (eventData.summary || '').toLowerCase();
105
+ const description = (eventData.description || '').toLowerCase();
106
+ const location = (eventData.location || '').toLowerCase();
107
+ const matchesSearch = summary.includes(searchTerm) ||
108
+ description.includes(searchTerm) ||
109
+ location.includes(searchTerm);
110
+ if (!matchesSearch) {
111
+ return [];
112
+ }
113
+ }
114
+ if (exclude_all_day) {
115
+ const isAllDay = ((_a = eventData.start) === null || _a === void 0 ? void 0 : _a.date) && !((_b = eventData.start) === null || _b === void 0 ? void 0 : _b.dateTime);
116
+ if (isAllDay) {
117
+ return [];
118
+ }
119
+ }
120
+ return [eventData];
121
+ }
122
+ else {
123
+ return [];
124
+ }
125
+ });
126
+ },
127
+ test(context) {
128
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
129
+ var _a, _b;
130
+ const auth = context.auth;
131
+ const { event_types, search_filter, exclude_all_day } = context.propsValue;
132
+ const latestEvent = yield (0, helper_1.getLatestEvent)(context.propsValue.calendar_id, auth);
133
+ if (event_types && event_types.length > 0) {
134
+ const eventType = latestEvent.eventType || 'default';
135
+ if (!event_types.includes(eventType)) {
136
+ return [];
137
+ }
138
+ }
139
+ if (search_filter && search_filter.trim()) {
140
+ const searchTerm = search_filter.toLowerCase().trim();
141
+ const summary = (latestEvent.summary || '').toLowerCase();
142
+ const description = (latestEvent.description || '').toLowerCase();
143
+ const location = (latestEvent.location || '').toLowerCase();
144
+ const matchesSearch = summary.includes(searchTerm) ||
145
+ description.includes(searchTerm) ||
146
+ location.includes(searchTerm);
147
+ if (!matchesSearch) {
148
+ return [];
149
+ }
150
+ }
151
+ if (exclude_all_day) {
152
+ const isAllDay = ((_a = latestEvent.start) === null || _a === void 0 ? void 0 : _a.date) && !((_b = latestEvent.start) === null || _b === void 0 ? void 0 : _b.dateTime);
153
+ if (isAllDay) {
154
+ return [];
155
+ }
156
+ }
157
+ return [latestEvent];
158
+ });
159
+ },
160
+ });
161
+ //# sourceMappingURL=new-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-event.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/triggers/new-event.ts"],"names":[],"mappings":";;;;AAAA,qEAKwC;AACxC,8BAA4C;AAC5C,sCAAiD;AACjD,6CAA8E;AAGjE,QAAA,QAAQ,GAAG,IAAA,gCAAa,EAAC;IACpC,IAAI,EAAE,sBAAkB;IACxB,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,kDAAkD;IAC/D,KAAK,EAAE;QACL,WAAW,EAAE,6BAAoB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;QAC5D,WAAW,EAAE,2BAAQ,CAAC,yBAAyB,CAAC;YAC9C,WAAW,EAAE,wBAAwB;YACrC,WAAW,EACT,yEAAyE;YAC3E,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE;oBAC7C,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE;oBAC/C,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE;oBAC3C,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE;oBAChD,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,EAAE;oBACvD,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE;iBAC5C;aACF;SACF,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,eAAe;YAC5B,WAAW,EACT,4FAA4F;YAC9F,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,eAAe,EAAE,2BAAQ,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