@activepieces/piece-google-calendar 0.0.0-pre1

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/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-google-calendar
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running lint
6
+
7
+ Run `nx lint pieces-google-calendar` to execute the lint via [ESLint](https://eslint.org/).
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@activepieces/piece-google-calendar",
3
+ "version": "0.0.0-pre1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "0.24.51",
6
+ "axios": "1.2.4",
7
+ "cron-validator": "1.3.1",
8
+ "nanoid": "3.3.4"
9
+ },
10
+ "peerDependencies": {
11
+ "@activepieces/framework": "0.0.1",
12
+ "@activepieces/shared": "0.0.1",
13
+ "tslib": "2.4.1"
14
+ },
15
+ "main": "./src/index.js",
16
+ "types": "./src/index.d.ts"
17
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const googleCalendar: import("@activepieces/framework").Piece;
package/src/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleCalendar = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const package_json_1 = tslib_1.__importDefault(require("../package.json"));
6
+ const framework_1 = require("@activepieces/framework");
7
+ const create_quick_event_1 = require("./lib/actions/create-quick-event");
8
+ const calendar_event_1 = require("./lib/triggers/calendar-event");
9
+ exports.googleCalendar = (0, framework_1.createPiece)({
10
+ name: 'google_calendar',
11
+ logoUrl: 'https://cdn.activepieces.com/pieces/google_calendar.png',
12
+ displayName: "Google Calendar",
13
+ version: package_json_1.default.version,
14
+ authors: ['osamahaikal'],
15
+ actions: [create_quick_event_1.createQuickCalendarEvent],
16
+ triggers: [calendar_event_1.calendarEventChanged],
17
+ });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/google-calendar/src/index.ts"],"names":[],"mappings":";;;;AAAA,2EAA0C;AAC1C,uDAAsD;AACtD,yEAA4E;AAC5E,kEAAqE;AAGxD,QAAA,cAAc,GAAG,IAAA,uBAAW,EAAC;IACzC,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,yDAAyD;IAClE,WAAW,EAAE,iBAAiB;IAC5B,OAAO,EAAE,sBAAW,CAAC,OAAO;IAC9B,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,OAAO,EAAE,CAAC,6CAAwB,CAAC;IACnC,QAAQ,EAAE,CAAC,qCAAoB,CAAC;CAChC,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const createQuickCalendarEvent: import("@activepieces/framework").Action;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createQuickCalendarEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const common_1 = require("../common");
7
+ exports.createQuickCalendarEvent = (0, framework_1.createAction)({
8
+ name: 'create_quick_event',
9
+ description: 'Add Quick Calendar Event',
10
+ displayName: 'Quick Event',
11
+ props: {
12
+ authentication: common_1.googleCalendarCommon.authentication,
13
+ calendar_id: common_1.googleCalendarCommon.calendarDropdown,
14
+ text: framework_1.Property.LongText({
15
+ displayName: 'Summary',
16
+ description: 'The text describing the event to be created',
17
+ required: true,
18
+ }),
19
+ send_updates: framework_1.Property.Dropdown({
20
+ displayName: "Send Updates",
21
+ description: "Guests who should receive notifications about the creation of the new event.",
22
+ refreshers: [],
23
+ required: false,
24
+ options: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
25
+ return {
26
+ disabled: false,
27
+ options: [
28
+ {
29
+ label: "All",
30
+ value: "all",
31
+ },
32
+ {
33
+ label: "External Only",
34
+ value: "externalOnly",
35
+ },
36
+ {
37
+ label: "none",
38
+ value: "none",
39
+ }
40
+ ]
41
+ };
42
+ })
43
+ }),
44
+ },
45
+ run(configValue) {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
+ // docs: https://developers.google.com/calendar/api/v3/reference/events/quickAdd
48
+ const calendarId = configValue.propsValue['calendar_id'];
49
+ const url = `${common_1.googleCalendarCommon.baseUrl}/calendars/${calendarId}/events/quickAdd`;
50
+ const qParams = {
51
+ text: configValue.propsValue['text'],
52
+ sendUpdates: configValue.propsValue['send_updates'] || "none",
53
+ };
54
+ const request = {
55
+ method: framework_1.HttpMethod.POST,
56
+ url,
57
+ body: {},
58
+ authentication: {
59
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
60
+ token: configValue.propsValue['authentication']['access_token'],
61
+ },
62
+ queryParams: qParams,
63
+ };
64
+ return yield framework_1.httpClient.sendRequest(request);
65
+ });
66
+ },
67
+ });
68
+ //# sourceMappingURL=create-quick-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-quick-event.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-calendar/src/lib/actions/create-quick-event.ts"],"names":[],"mappings":";;;;AAAA,uDAA0H;AAC1H,sCAAiD;AAEpC,QAAA,wBAAwB,GAAG,IAAA,wBAAY,EAAC;IACnD,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,0BAA0B;IACvC,WAAW,EAAE,aAAa;IAC1B,KAAK,EAAE;QACL,cAAc,EAAE,6BAAoB,CAAC,cAAc;QACnD,WAAW,EAAE,6BAAoB,CAAC,gBAAgB;QAClD,IAAI,EAAE,oBAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAS;YACtC,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,8EAA8E;YAC3F,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,GAAS,EAAE;gBAClB,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE;wBACP;4BACE,KAAK,EAAE,KAAK;4BACZ,KAAK,EAAE,KAAK;yBACb;wBACD;4BACE,KAAK,EAAE,eAAe;4BACtB,KAAK,EAAE,cAAc;yBACtB;wBACD;4BACE,KAAK,EAAE,MAAM;4BACb,KAAK,EAAE,MAAM;yBACd;qBACF;iBACF,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACK,GAAG,CAAC,WAAW;;YACnB,gFAAgF;YAChF,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACzD,MAAM,GAAG,GAAG,GAAG,6BAAoB,CAAC,OAAO,cAAc,UAAU,kBAAkB,CAAC;YACtF,MAAM,OAAO,GAA2B;gBACtC,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,MAAM,CAAE;gBACrC,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,MAAM;aAC9D,CAAC;YACF,MAAM,OAAO,GAAyC;gBACpD,MAAM,EAAE,sBAAU,CAAC,IAAI;gBACvB,GAAG;gBACH,IAAI,EAAE,EAAE;gBACR,cAAc,EAAE;oBACd,IAAI,EAAE,8BAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,gBAAgB,CAAE,CAAC,cAAc,CAAC;iBACjE;gBACD,WAAW,EAAE,OAAO;aACrB,CAAC;YACF,OAAO,MAAM,sBAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC/C,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { OAuth2PropertyValue } from "@activepieces/framework";
2
+ import { GoogleWatchResponse, CalendarObject, GoogleCalendarEvent } from "./types";
3
+ export declare function stopWatchEvent(body: GoogleWatchResponse, authProp: OAuth2PropertyValue): Promise<void>;
4
+ export declare function watchEvent(calendarId: string, webhookUrl: string, authProp: OAuth2PropertyValue): Promise<GoogleWatchResponse>;
5
+ export declare function getCalendars(authProp: OAuth2PropertyValue): Promise<CalendarObject[]>;
6
+ export declare function getLatestEvent(calendarId: string, authProp: OAuth2PropertyValue): Promise<GoogleCalendarEvent>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestEvent = exports.getCalendars = exports.watchEvent = exports.stopWatchEvent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const crypto_1 = require("crypto");
7
+ const _1 = require(".");
8
+ const types_1 = require("./types");
9
+ function stopWatchEvent(body, authProp) {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
+ const request = {
12
+ method: framework_1.HttpMethod.POST,
13
+ url: `${_1.googleCalendarCommon.baseUrl}/channels/stop`,
14
+ body: {
15
+ id: body === null || body === void 0 ? void 0 : body.id,
16
+ resourceId: body === null || body === void 0 ? void 0 : body.resourceId,
17
+ },
18
+ authentication: {
19
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
20
+ token: authProp.access_token,
21
+ },
22
+ };
23
+ yield framework_1.httpClient.sendRequest(request);
24
+ });
25
+ }
26
+ exports.stopWatchEvent = stopWatchEvent;
27
+ function watchEvent(calendarId, webhookUrl, authProp) {
28
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
+ const request = {
30
+ method: framework_1.HttpMethod.POST,
31
+ url: `${_1.googleCalendarCommon.baseUrl}/calendars/${calendarId}/events/watch`,
32
+ body: {
33
+ id: (0, crypto_1.randomUUID)(),
34
+ type: types_1.GoogleWatchType.WEBHOOK,
35
+ address: webhookUrl,
36
+ },
37
+ authentication: {
38
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
39
+ token: authProp.access_token,
40
+ },
41
+ };
42
+ const { body: webhook } = yield framework_1.httpClient.sendRequest(request);
43
+ return webhook;
44
+ });
45
+ }
46
+ exports.watchEvent = watchEvent;
47
+ function getCalendars(authProp) {
48
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
+ // docs: https://developers.google.com/calendar/api/v3/reference/calendarList/list
50
+ const request = {
51
+ method: framework_1.HttpMethod.GET,
52
+ url: `${_1.googleCalendarCommon.baseUrl}/users/me/calendarList`,
53
+ authentication: {
54
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
55
+ token: authProp.access_token,
56
+ },
57
+ };
58
+ const response = yield framework_1.httpClient.sendRequest(request);
59
+ return response.body.items;
60
+ });
61
+ }
62
+ exports.getCalendars = getCalendars;
63
+ function getLatestEvent(calendarId, authProp) {
64
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
65
+ // docs: https://developers.google.com/calendar/api/v3/reference/events/list
66
+ const now = new Date();
67
+ const yesterday = new Date();
68
+ yesterday.setDate(now.getDate() - 1);
69
+ const qParams = {
70
+ updatedMin: yesterday.toISOString(),
71
+ maxResults: '2500',
72
+ orderBy: 'updated',
73
+ singleEvents: 'true',
74
+ showDeleted: 'true',
75
+ };
76
+ const request = {
77
+ method: framework_1.HttpMethod.GET,
78
+ url: `${_1.googleCalendarCommon.baseUrl}/calendars/${calendarId}/events`,
79
+ queryParams: qParams,
80
+ authentication: {
81
+ type: framework_1.AuthenticationType.BEARER_TOKEN,
82
+ token: authProp.access_token,
83
+ },
84
+ };
85
+ let eventList = [];
86
+ let pageToken = '';
87
+ do {
88
+ qParams['pageToken'] = pageToken;
89
+ const { body: res } = yield framework_1.httpClient.sendRequest(request);
90
+ if (res.items.length > 0) {
91
+ eventList = [...eventList, ...res.items];
92
+ }
93
+ pageToken = res.nextPageToken;
94
+ } while (pageToken);
95
+ const lastUpdatedEvent = eventList.pop(); // You can retrieve the last updated event.
96
+ return lastUpdatedEvent;
97
+ });
98
+ }
99
+ exports.getLatestEvent = getLatestEvent;
100
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../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,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,sBAAU,CAAC,WAAW,CAChD,OAAO,CACR,CAAC;YACF,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACxB,SAAS,GAAG,CAAC,GAAG,SAAS,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;aAC1C;YACD,SAAS,GAAG,GAAG,CAAC,aAAa,CAAC;SAC/B,QAAQ,SAAS,EAAE;QACpB,MAAM,gBAAgB,GAAG,SAAS,CAAC,GAAG,EAAG,CAAC,CAAC,2CAA2C;QACtF,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CAAA;AAzCD,wCAyCC"}
@@ -0,0 +1,5 @@
1
+ export declare const googleCalendarCommon: {
2
+ baseUrl: string;
3
+ authentication: import("@activepieces/framework").OAuth2Property<true>;
4
+ calendarDropdown: import("@activepieces/framework").DropdownProperty<string, false> | import("@activepieces/framework").DropdownProperty<string, true>;
5
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleCalendarCommon = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const helper_1 = require("./helper");
7
+ exports.googleCalendarCommon = {
8
+ baseUrl: 'https://www.googleapis.com/calendar/v3',
9
+ authentication: framework_1.Property.OAuth2({
10
+ description: '',
11
+ displayName: 'Authentication 2',
12
+ authUrl: 'https://accounts.google.com/o/oauth2/auth',
13
+ tokenUrl: 'https://oauth2.googleapis.com/token',
14
+ required: true,
15
+ pkce: true,
16
+ scope: ['https://www.googleapis.com/auth/calendar'],
17
+ }),
18
+ calendarDropdown: framework_1.Property.Dropdown({
19
+ displayName: 'Calendar',
20
+ refreshers: ['authentication'],
21
+ required: true,
22
+ options: (propsValue) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
23
+ if (!propsValue['authentication']) {
24
+ return {
25
+ disabled: true,
26
+ options: [],
27
+ };
28
+ }
29
+ const authProp = propsValue['authentication'];
30
+ const calendars = yield (0, helper_1.getCalendars)(authProp);
31
+ return {
32
+ disabled: false,
33
+ options: calendars.map((calendar) => {
34
+ return {
35
+ label: calendar.summary,
36
+ value: calendar.id,
37
+ };
38
+ }),
39
+ };
40
+ }),
41
+ }),
42
+ };
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-calendar/src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAwE;AACxE,qCAAwC;AAE3B,QAAA,oBAAoB,GAAG;IAClC,OAAO,EAAE,wCAAwC;IACjD,cAAc,EAAE,oBAAQ,CAAC,MAAM,CAAC;QAC9B,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,qCAAqC;QAC/C,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,CAAC,0CAA0C,CAAC;KACpD,CAAC;IACF,gBAAgB,EAAE,oBAAQ,CAAC,QAAQ,CAAS;QAC1C,WAAW,EAAE,UAAU;QACvB,UAAU,EAAE,CAAC,gBAAgB,CAAC;QAC9B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,CAAO,UAAU,EAAE,EAAE;YAC5B,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;gBACjC,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;iBACZ,CAAC;aACH;YACD,MAAM,QAAQ,GAAwB,UAAU,CAC9C,gBAAgB,CACM,CAAC;YACzB,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAY,EAAC,QAAQ,CAAC,CAAC;YAC/C,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;oBAClC,OAAO;wBACL,KAAK,EAAE,QAAQ,CAAC,OAAO;wBACvB,KAAK,EAAE,QAAQ,CAAC,EAAE;qBACnB,CAAC;gBACJ,CAAC,CAAC;aACH,CAAC;QACJ,CAAC,CAAA;KACF,CAAC;CACH,CAAC"}
@@ -0,0 +1,223 @@
1
+ export declare enum GoogleWatchType {
2
+ WEBHOOK = "web_hook"
3
+ }
4
+ export declare enum GoogleCalendarKind {
5
+ CALENDAR_LIST = "calendar#calendarList",
6
+ CALENDAR_ENTRY = "calendar#calendarListEntry",
7
+ CALENDAR_EVENT = "calendar#event",
8
+ CALENDAR_EVENT_LIST = "calendar#events",
9
+ EVENT_WATCH = "api#channel"
10
+ }
11
+ export interface CalendarList {
12
+ kind: GoogleCalendarKind.CALENDAR_LIST;
13
+ etag: string;
14
+ nextPageToken: string;
15
+ nextSyncToken: string;
16
+ items: CalendarObject[];
17
+ }
18
+ export interface CalendarObject {
19
+ kind: GoogleCalendarKind.CALENDAR_ENTRY;
20
+ etag: string;
21
+ id: string;
22
+ summary: string;
23
+ description: string;
24
+ location: string;
25
+ timeZone: string;
26
+ summaryOverride: string;
27
+ colorId: string;
28
+ backgroundColor: string;
29
+ foregroundColor: string;
30
+ hidden: boolean;
31
+ selected: boolean;
32
+ accessRole: string;
33
+ defaultReminders: [
34
+ {
35
+ method: string;
36
+ minutes: number;
37
+ }
38
+ ];
39
+ notificationSettings: {
40
+ notifications: [
41
+ {
42
+ type: string;
43
+ method: string;
44
+ }
45
+ ];
46
+ };
47
+ primary: boolean;
48
+ deleted: boolean;
49
+ conferenceProperties: {
50
+ allowedConferenceSolutionTypes: string[];
51
+ };
52
+ }
53
+ export interface GoogleWatchResponse {
54
+ kind: GoogleCalendarKind.EVENT_WATCH;
55
+ id: string;
56
+ resourceId: string;
57
+ resourceUri: string;
58
+ token: string;
59
+ expiration: number;
60
+ }
61
+ interface Attendee {
62
+ id: string;
63
+ email: string;
64
+ displayName: string;
65
+ organizer: boolean;
66
+ self: boolean;
67
+ resource: boolean;
68
+ optional: boolean;
69
+ responseStatus: string;
70
+ comment: string;
71
+ additionalGuests: BigInteger;
72
+ }
73
+ export interface GoogleCalendarEvent {
74
+ kind: GoogleCalendarKind.CALENDAR_EVENT;
75
+ etag: string;
76
+ id: string;
77
+ status: string;
78
+ htmlLink: string;
79
+ created: Date;
80
+ updated: Date;
81
+ summary: string;
82
+ description: string;
83
+ location: string;
84
+ colorId: string;
85
+ creator: {
86
+ id: string;
87
+ email: string;
88
+ displayName: string;
89
+ self: boolean;
90
+ };
91
+ organizer: {
92
+ id: string;
93
+ email: string;
94
+ displayName: string;
95
+ self: boolean;
96
+ };
97
+ start: {
98
+ date: Date;
99
+ dateTime: Date;
100
+ timeZone: string;
101
+ };
102
+ end: {
103
+ date: Date;
104
+ dateTime: Date;
105
+ timeZone: string;
106
+ };
107
+ endTimeUnspecified: boolean;
108
+ recurrence: [string];
109
+ recurringEventId: string;
110
+ originalStartTime: {
111
+ date: Date;
112
+ dateTime: Date;
113
+ timeZone: string;
114
+ };
115
+ transparency: string;
116
+ visibility: string;
117
+ iCalUID: string;
118
+ sequence: BigInteger;
119
+ attendees: Attendee[];
120
+ attendeesOmitted: boolean;
121
+ extendedProperties: {
122
+ private: {
123
+ key: string;
124
+ };
125
+ shared: {
126
+ key: string;
127
+ };
128
+ };
129
+ hangoutLink: string;
130
+ conferenceData: {
131
+ createRequest: {
132
+ requestId: string;
133
+ conferenceSolutionKey: {
134
+ type: string;
135
+ };
136
+ status: {
137
+ statusCode: string;
138
+ };
139
+ };
140
+ entryPoints: [
141
+ {
142
+ entryPointType: string;
143
+ uri: string;
144
+ label: string;
145
+ pin: string;
146
+ accessCode: string;
147
+ meetingCode: string;
148
+ passcode: string;
149
+ password: string;
150
+ }
151
+ ];
152
+ conferenceSolution: {
153
+ key: {
154
+ type: string;
155
+ };
156
+ name: string;
157
+ iconUri: string;
158
+ };
159
+ conferenceId: string;
160
+ signature: string;
161
+ notes: string;
162
+ };
163
+ gadget: {
164
+ type: string;
165
+ title: string;
166
+ link: string;
167
+ iconLink: string;
168
+ width: BigInteger;
169
+ height: BigInteger;
170
+ display: string;
171
+ preferences: {
172
+ key: string;
173
+ };
174
+ };
175
+ anyoneCanAddSelf: boolean;
176
+ guestsCanInviteOthers: boolean;
177
+ guestsCanModify: boolean;
178
+ guestsCanSeeOtherGuests: boolean;
179
+ privateCopy: boolean;
180
+ locked: boolean;
181
+ reminders: {
182
+ useDefault: boolean;
183
+ overrides: [
184
+ {
185
+ method: string;
186
+ minutes: BigInteger;
187
+ }
188
+ ];
189
+ };
190
+ source: {
191
+ url: string;
192
+ title: string;
193
+ };
194
+ attachments: [
195
+ {
196
+ fileUrl: string;
197
+ title: string;
198
+ mimeType: string;
199
+ iconLink: string;
200
+ fileId: string;
201
+ }
202
+ ];
203
+ eventType: string;
204
+ }
205
+ export interface GoogleCalendarEventList {
206
+ kind: GoogleCalendarKind.CALENDAR_EVENT_LIST;
207
+ etag: string;
208
+ summary: string;
209
+ description: string;
210
+ updated: number;
211
+ timeZone: string;
212
+ accessRole: string;
213
+ defaultReminders: [
214
+ {
215
+ method: string;
216
+ minutes: BigInteger;
217
+ }
218
+ ];
219
+ nextPageToken: string;
220
+ nextSyncToken: string;
221
+ items: GoogleCalendarEvent[];
222
+ }
223
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleCalendarKind = exports.GoogleWatchType = void 0;
4
+ var GoogleWatchType;
5
+ (function (GoogleWatchType) {
6
+ GoogleWatchType["WEBHOOK"] = "web_hook";
7
+ })(GoogleWatchType = exports.GoogleWatchType || (exports.GoogleWatchType = {}));
8
+ var GoogleCalendarKind;
9
+ (function (GoogleCalendarKind) {
10
+ GoogleCalendarKind["CALENDAR_LIST"] = "calendar#calendarList";
11
+ GoogleCalendarKind["CALENDAR_ENTRY"] = "calendar#calendarListEntry";
12
+ GoogleCalendarKind["CALENDAR_EVENT"] = "calendar#event";
13
+ GoogleCalendarKind["CALENDAR_EVENT_LIST"] = "calendar#events";
14
+ GoogleCalendarKind["EVENT_WATCH"] = "api#channel";
15
+ })(GoogleCalendarKind = exports.GoogleCalendarKind || (exports.GoogleCalendarKind = {}));
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-calendar/src/lib/common/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAEX;AAFD,WAAY,eAAe;IACzB,uCAAoB,CAAA;AACtB,CAAC,EAFW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAE1B;AAED,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,6DAAuC,CAAA;IACvC,mEAA6C,CAAA;IAC7C,uDAAiC,CAAA;IACjC,6DAAuC,CAAA;IACvC,iDAA2B,CAAA;AAC7B,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B"}
@@ -0,0 +1 @@
1
+ export declare const calendarEventChanged: import("@activepieces/framework").Trigger;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calendarEventChanged = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@activepieces/framework");
6
+ const common_1 = require("../common");
7
+ const helper_1 = require("../common/helper");
8
+ exports.calendarEventChanged = (0, framework_1.createTrigger)({
9
+ // docs: https://developers.google.com/calendar/api/guides/push
10
+ name: 'new_or_updated_event',
11
+ displayName: 'New Or updated Event',
12
+ description: 'Triggers when there is an event added or updated',
13
+ props: {
14
+ authentication: common_1.googleCalendarCommon.authentication,
15
+ calendar_id: common_1.googleCalendarCommon.calendarDropdown,
16
+ },
17
+ sampleData: {
18
+ kind: 'calendar#event',
19
+ etag: "3350849506974000",
20
+ id: "0nsfi5ttd2b17ac76ma2f37oi9",
21
+ htmlLink: 'https://www.google.com/calendar/event?eid=kgjb90uioj4klrgfmdsnjsjvlgkm',
22
+ summary: 'ap-event-test',
23
+ created: "2023-02-03T11:36:36.000Z",
24
+ updated: "2023-02-03T11:45:53.487Z",
25
+ description: 'Sample description',
26
+ status: 'canceled',
27
+ creator: {
28
+ email: 'test@test.com',
29
+ self: true
30
+ },
31
+ organizer: {
32
+ email: 'test@test.com',
33
+ self: true
34
+ },
35
+ start: {
36
+ dateTime: '2023-02-02T22:30:00+03:00',
37
+ timeZone: 'Asia/Amman',
38
+ },
39
+ end: {
40
+ dateTime: '2023-02-02T23:30:00+03:00',
41
+ timeZone: 'Asia/Amman',
42
+ },
43
+ transparency: 'transparent',
44
+ iCalUID: "0nsfi5ttd2b17ac76ma2f37oi9@google.com",
45
+ sequence: 1,
46
+ attendees: [
47
+ {
48
+ email: 'attende@test.com',
49
+ responseStatus: 'needsAction'
50
+ },
51
+ {
52
+ email: 'test@test.com',
53
+ organizer: true,
54
+ self: true,
55
+ responseStatus: 'accepted'
56
+ },
57
+ ],
58
+ reminders: {
59
+ useDefault: true
60
+ },
61
+ eventType: 'default',
62
+ },
63
+ type: framework_1.TriggerStrategy.WEBHOOK,
64
+ onEnable(context) {
65
+ var _a, _b;
66
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
67
+ const authProp = context.propsValue['authentication'];
68
+ const currentChannel = yield ((_a = context.store) === null || _a === void 0 ? void 0 : _a.get('_trigger'));
69
+ if (currentChannel === null || currentChannel === void 0 ? void 0 : currentChannel.id) {
70
+ yield (0, helper_1.stopWatchEvent)(currentChannel, authProp); // to avoid creating multiple watchers
71
+ }
72
+ const calendarId = context.propsValue['calendar_id'];
73
+ const channel = yield (0, helper_1.watchEvent)(calendarId, context.webhookUrl, authProp);
74
+ yield ((_b = context.store) === null || _b === void 0 ? void 0 : _b.put('_trigger', channel));
75
+ });
76
+ },
77
+ onDisable(context) {
78
+ var _a, _b;
79
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
80
+ const authProp = context.propsValue['authentication'];
81
+ const googleChannel = yield ((_a = context.store) === null || _a === void 0 ? void 0 : _a.get('_trigger'));
82
+ if (googleChannel === null || googleChannel === void 0 ? void 0 : googleChannel.id)
83
+ yield (0, helper_1.stopWatchEvent)(googleChannel, authProp);
84
+ yield ((_b = context.store) === null || _b === void 0 ? void 0 : _b.put('_trigger', {}));
85
+ });
86
+ },
87
+ run(context) {
88
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
89
+ const authProp = context.propsValue['authentication'];
90
+ const event = yield (0, helper_1.getLatestEvent)(context.propsValue['calendar_id'], authProp);
91
+ return [event];
92
+ });
93
+ },
94
+ });
95
+ //# sourceMappingURL=calendar-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-event.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/google-calendar/src/lib/triggers/calendar-event.ts"],"names":[],"mappings":";;;;AAAA,uDAA8F;AAC9F,sCAAiD;AACjD,6CAA8E;AAGjE,QAAA,oBAAoB,GAAG,IAAA,yBAAa,EAAC;IAChD,+DAA+D;IAC/D,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,kDAAkD;IAC/D,KAAK,EAAE;QACL,cAAc,EAAE,6BAAoB,CAAC,cAAc;QACnD,WAAW,EAAE,6BAAoB,CAAC,gBAAgB;KACnD;IACD,UAAU,EAAE;QACV,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,kBAAkB;QACxB,EAAE,EAAE,4BAA4B;QAChC,QAAQ,EAAE,wEAAwE;QAClF,OAAO,EAAE,eAAe;QACxB,OAAO,EAAE,0BAA0B;QACnC,OAAO,EAAE,0BAA0B;QACnC,WAAW,EAAE,oBAAoB;QACjC,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE;YACP,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,IAAI;SACX;QACD,SAAS,EAAE;YACT,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,IAAI;SACX;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,2BAA2B;YACrC,Q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