@scopieflows/app-google-calendar 0.8.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 (75) hide show
  1. package/README.md +7 -0
  2. package/package.json +30 -0
  3. package/src/i18n/ca.json +71 -0
  4. package/src/i18n/de.json +151 -0
  5. package/src/i18n/es.json +151 -0
  6. package/src/i18n/fr.json +151 -0
  7. package/src/i18n/hi.json +71 -0
  8. package/src/i18n/id.json +71 -0
  9. package/src/i18n/ja.json +151 -0
  10. package/src/i18n/nl.json +151 -0
  11. package/src/i18n/pt.json +151 -0
  12. package/src/i18n/ru.json +71 -0
  13. package/src/i18n/translation.json +151 -0
  14. package/src/i18n/vi.json +71 -0
  15. package/src/i18n/zh.json +151 -0
  16. package/src/index.d.ts +2 -0
  17. package/src/index.js +90 -0
  18. package/src/index.js.map +1 -0
  19. package/src/lib/actions/add-attendees.action.d.ts +5 -0
  20. package/src/lib/actions/add-attendees.action.js +54 -0
  21. package/src/lib/actions/add-attendees.action.js.map +1 -0
  22. package/src/lib/actions/add-calendar-to-calendarlist.d.ts +3 -0
  23. package/src/lib/actions/add-calendar-to-calendarlist.js +36 -0
  24. package/src/lib/actions/add-calendar-to-calendarlist.js.map +1 -0
  25. package/src/lib/actions/create-event.d.ts +15 -0
  26. package/src/lib/actions/create-event.js +149 -0
  27. package/src/lib/actions/create-event.js.map +1 -0
  28. package/src/lib/actions/create-quick-event.d.ts +5 -0
  29. package/src/lib/actions/create-quick-event.js +67 -0
  30. package/src/lib/actions/create-quick-event.js.map +1 -0
  31. package/src/lib/actions/delete-event.action.d.ts +4 -0
  32. package/src/lib/actions/delete-event.action.js +37 -0
  33. package/src/lib/actions/delete-event.action.js.map +1 -0
  34. package/src/lib/actions/find-busy-free-periods.d.ts +5 -0
  35. package/src/lib/actions/find-busy-free-periods.js +78 -0
  36. package/src/lib/actions/find-busy-free-periods.js.map +1 -0
  37. package/src/lib/actions/get-event-by-id.d.ts +6 -0
  38. package/src/lib/actions/get-event-by-id.js +93 -0
  39. package/src/lib/actions/get-event-by-id.js.map +1 -0
  40. package/src/lib/actions/get-events.d.ts +8 -0
  41. package/src/lib/actions/get-events.js +99 -0
  42. package/src/lib/actions/get-events.js.map +1 -0
  43. package/src/lib/actions/update-event.action.d.ts +14 -0
  44. package/src/lib/actions/update-event.action.js +114 -0
  45. package/src/lib/actions/update-event.action.js.map +1 -0
  46. package/src/lib/common/helper.d.ts +12 -0
  47. package/src/lib/common/helper.js +191 -0
  48. package/src/lib/common/helper.js.map +1 -0
  49. package/src/lib/common/index.d.ts +6 -0
  50. package/src/lib/common/index.js +94 -0
  51. package/src/lib/common/index.js.map +1 -0
  52. package/src/lib/common/types.d.ts +239 -0
  53. package/src/lib/common/types.js +17 -0
  54. package/src/lib/common/types.js.map +1 -0
  55. package/src/lib/triggers/calendar-event.d.ts +14 -0
  56. package/src/lib/triggers/calendar-event.js +144 -0
  57. package/src/lib/triggers/calendar-event.js.map +1 -0
  58. package/src/lib/triggers/event-cancelled.d.ts +22 -0
  59. package/src/lib/triggers/event-cancelled.js +165 -0
  60. package/src/lib/triggers/event-cancelled.js.map +1 -0
  61. package/src/lib/triggers/event-ends.d.ts +18 -0
  62. package/src/lib/triggers/event-ends.js +167 -0
  63. package/src/lib/triggers/event-ends.js.map +1 -0
  64. package/src/lib/triggers/event-start-time-before.d.ts +26 -0
  65. package/src/lib/triggers/event-start-time-before.js +161 -0
  66. package/src/lib/triggers/event-start-time-before.js.map +1 -0
  67. package/src/lib/triggers/new-calendar.d.ts +18 -0
  68. package/src/lib/triggers/new-calendar.js +151 -0
  69. package/src/lib/triggers/new-calendar.js.map +1 -0
  70. package/src/lib/triggers/new-event-matching-search.d.ts +22 -0
  71. package/src/lib/triggers/new-event-matching-search.js +185 -0
  72. package/src/lib/triggers/new-event-matching-search.js.map +1 -0
  73. package/src/lib/triggers/new-event.d.ts +22 -0
  74. package/src/lib/triggers/new-event.js +161 -0
  75. package/src/lib/triggers/new-event.js.map +1 -0
@@ -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("@scopieflows/pieces-framework");
6
+ const pieces_framework_2 = require("@scopieflows/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const __1 = require("../../");
9
+ const pieces_common_1 = require("@scopieflows/pieces-common");
10
+ const pieces_common_2 = require("@scopieflows/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":"","sources":["../../../../../../../../packages/pieces/community/google-calendar/src/lib/triggers/event-ends.ts"],"names":[],"mappings":";;;;AAAA,oEAIuC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3C,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;QAC/B,SAAS,EAAE,SAAS;KACrB;IAEK,QAAQ,CAAC,OAAO;;YACpB,MAAM,6BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE;gBACpC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,SAAS,CAAC,OAAO;;YACrB,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE;gBACrC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,GAAG,CAAC,OAAO;;YACf,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;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,26 @@
1
+ import { TriggerStrategy } from '@scopieflows/pieces-framework';
2
+ export declare const eventStartTimeBefore: import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
3
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
4
+ specific_event: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
5
+ event_id: import("@scopieflows/pieces-framework").DropdownProperty<string, false, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>> | import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
6
+ time_value: import("@scopieflows/pieces-framework").NumberProperty<true>;
7
+ time_unit: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, true>;
8
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
9
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
10
+ specific_event: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
11
+ event_id: import("@scopieflows/pieces-framework").DropdownProperty<string, false, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>> | import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
12
+ time_value: import("@scopieflows/pieces-framework").NumberProperty<true>;
13
+ time_unit: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, true>;
14
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
15
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
16
+ specific_event: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
17
+ event_id: import("@scopieflows/pieces-framework").DropdownProperty<string, false, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>> | import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
18
+ time_value: import("@scopieflows/pieces-framework").NumberProperty<true>;
19
+ time_unit: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, true>;
20
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
21
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
22
+ specific_event: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
23
+ event_id: import("@scopieflows/pieces-framework").DropdownProperty<string, false, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>> | import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
24
+ time_value: import("@scopieflows/pieces-framework").NumberProperty<true>;
25
+ time_unit: import("@scopieflows/pieces-framework").StaticDropdownProperty<string, true>;
26
+ }>;
@@ -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("@scopieflows/pieces-framework");
6
+ const pieces_framework_2 = require("@scopieflows/pieces-framework");
7
+ const common_1 = require("../common");
8
+ const __1 = require("../../");
9
+ const pieces_common_1 = require("@scopieflows/pieces-common");
10
+ const pieces_common_2 = require("@scopieflows/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,oEAKuC;AACvC,oEAAgE;AAChE,sCAAiD;AAEjD,8BAA4C;AAC5C,8DAIoC;AACpC,8DAKoC;AAMpC,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,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
+ export declare const newCalendar: import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
3
+ access_role_filter: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
4
+ calendar_name_filter: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
5
+ exclude_shared: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
6
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
7
+ access_role_filter: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
8
+ calendar_name_filter: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
9
+ exclude_shared: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
10
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
11
+ access_role_filter: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
12
+ calendar_name_filter: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
13
+ exclude_shared: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
14
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
15
+ access_role_filter: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
16
+ calendar_name_filter: import("@scopieflows/pieces-framework").ShortTextProperty<false>;
17
+ exclude_shared: import("@scopieflows/pieces-framework").CheckboxProperty<false>;
18
+ }>;
@@ -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("@scopieflows/pieces-framework");
6
+ const pieces_framework_2 = require("@scopieflows/pieces-framework");
7
+ const __1 = require("../../");
8
+ const pieces_common_1 = require("@scopieflows/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,oEAIuC;AACvC,oEAAgE;AAChE,8BAA4C;AAC5C,8DAIoC;AACpC,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,QAAQ,CAAC,UAAU,CAAC,CAAA,CAAA;aAAA,CACtD,CAAC;QACJ,CAAC;QAED,IAAI,cAAc,EAAE,CAAC;YACnB,iBAAiB,GAAG,i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AA;CACF,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { TriggerStrategy } from '@scopieflows/pieces-framework';
2
+ export declare const newEventMatchingSearch: import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
3
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
4
+ search_term: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
5
+ event_types: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
6
+ search_fields: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
7
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
8
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
9
+ search_term: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
10
+ event_types: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
11
+ search_fields: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
12
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
13
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
14
+ search_term: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
15
+ event_types: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
16
+ search_fields: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
17
+ }> | import("@scopieflows/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>, {
18
+ calendar_id: import("@scopieflows/pieces-framework").DropdownProperty<string, true, import("@scopieflows/pieces-framework").OAuth2Property<import("@scopieflows/pieces-framework").OAuth2Props>>;
19
+ search_term: import("@scopieflows/pieces-framework").ShortTextProperty<true>;
20
+ event_types: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
21
+ search_fields: import("@scopieflows/pieces-framework").StaticMultiSelectDropdownProperty<string, false>;
22
+ }>;