Skip to content

Commit 750ff1d

Browse files
authored
Fix long load times for async options in Google components (#2444)
* Fix long load times for async options in Google components Replaces googleapis dependency with @googleapis/ submodules to reduce startup times - `@googleapis/drive` - `@googleapis/sheets` - `@googleapis/docs` - `@googleapis/calendar` - `@googleapis/youtube` * Add package.json for Google Docs app * Fix JSDocs in Youtube app and source Changes import from 'googleapis' to '@googleapis/youtube' for @typedefs * Bump versions of Google components Bumps versions of components for apps: - Google Drive - Google Sheets - Google Docs - Google Calendar - Youtube Fix linter errors in Google Calendar components & Google Drive Create New File From Template action
1 parent bf943cb commit 750ff1d

File tree

82 files changed

+643
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+643
-249
lines changed

components/google_calendar/google_calendar.app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { google } = require("googleapis");
1+
const googleCalendar = require("@googleapis/calendar");
22

33
module.exports = {
44
type: "app",
@@ -127,9 +127,9 @@ module.exports = {
127127
};
128128
},
129129
calendar() {
130-
const auth = new google.auth.OAuth2();
130+
const auth = new googleCalendar.auth.OAuth2();
131131
auth.setCredentials(this._tokens());
132-
const calendar = google.calendar({
132+
const calendar = googleCalendar.calendar({
133133
version: "v3",
134134
auth,
135135
});

components/google_calendar/package-lock.json

Lines changed: 39 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/google_calendar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"license": "MIT",
1313
"dependencies": {
14-
"googleapis": "^67.0.0",
14+
"@googleapis/calendar": "^1.0.2",
1515
"lodash.get": "^4.4.2"
1616
},
1717
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",

components/google_calendar/sources/event-cancelled/event-cancelled.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
key: "google_calendar-event-cancelled",
66
name: "Event Cancelled",
77
description: "Emits when an event is cancelled or deleted",
8-
version: "0.0.1",
8+
version: "0.0.2",
9+
type: "source",
910
dedupe: "unique", // Dedupe events based on the Google Calendar event ID
1011
props: {
1112
googleCalendar,
@@ -16,7 +17,10 @@ module.exports = {
1617
const calendars = _.get(calListResp, "data.items");
1718
if (calendars) {
1819
const calendarIds = calendars.map((item) => {
19-
return { value: item.id, label: item.summary };
20+
return {
21+
value: item.id,
22+
label: item.summary,
23+
};
2024
});
2125
return calendarIds;
2226
}
@@ -50,7 +54,10 @@ module.exports = {
5054
for (const event of events) {
5155
// only emit if status is cancelled
5256
if (event.status === "cancelled") {
53-
const { summary, id } = event;
57+
const {
58+
summary,
59+
id,
60+
} = event;
5461
this.$emit(event, {
5562
summary,
5663
id,

components/google_calendar/sources/event-ended/event-ended.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
key: "google_calendar-event-ended",
66
name: "Event Ended",
77
description: "Emits when an event ends",
8-
version: "0.0.1",
8+
version: "0.0.2",
9+
type: "source",
910
dedupe: "unique", // Dedupe events based on the Google Calendar event ID
1011
props: {
1112
googleCalendar,
@@ -16,7 +17,10 @@ module.exports = {
1617
const calendars = _.get(calListResp, "data.items");
1718
if (calendars) {
1819
const calendarIds = calendars.map((item) => {
19-
return { value: item.id, label: item.summary };
20+
return {
21+
value: item.id,
22+
label: item.summary,
23+
};
2024
});
2125
return calendarIds;
2226
}
@@ -53,7 +57,10 @@ module.exports = {
5357
const end = new Date(eventEnd);
5458
const msFromEnd = now.getTime() - end.getTime();
5559
if (eventEnd && msFromEnd > 0 && msFromEnd < intervalMs) {
56-
const { summary, id } = event;
60+
const {
61+
summary,
62+
id,
63+
} = event;
5764
this.$emit(event, {
5865
summary,
5966
id,

components/google_calendar/sources/event-search/new-event-search.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ module.exports = {
55
key: "google_calendar-new-event-search",
66
name: "Event Search",
77
description: "Emit when an event is created that matches a search",
8-
version: "0.0.1",
8+
version: "0.0.2",
9+
type: "source",
910
dedupe: "unique", // Dedupe events based on the Google Calendar event ID
1011
props: {
1112
googleCalendar,
1213
q: {
13-
propDefinition: [googleCalendar, "q"],
14+
propDefinition: [
15+
googleCalendar,
16+
"q",
17+
],
1418
},
1519
calendarId: {
1620
type: "string",
@@ -19,7 +23,10 @@ module.exports = {
1923
const calendars = _.get(calListResp, "data.items");
2024
if (calendars) {
2125
const calendarIds = calendars.map((item) => {
22-
return { value: item.id, label: item.summary };
26+
return {
27+
value: item.id,
28+
label: item.summary,
29+
};
2330
});
2431
return calendarIds;
2532
}
@@ -55,7 +62,10 @@ module.exports = {
5562
const created = new Date(event.created);
5663
// created in last 5 mins and not cancelled
5764
if (created > past && event.status !== "cancelled") {
58-
const { summary, id } = event;
65+
const {
66+
summary,
67+
id,
68+
} = event;
5969
this.$emit(event, {
6070
summary,
6171
id,

components/google_calendar/sources/event-start/event-start.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
key: "google_calendar-event-start",
66
name: "Event Start",
77
description: "Emits a specified time before an event starts",
8-
version: "0.0.1",
8+
version: "0.0.2",
9+
type: "source",
910
dedupe: "unique", // Dedupe events based on the Google Calendar event ID
1011
props: {
1112
googleCalendar,
@@ -16,7 +17,10 @@ module.exports = {
1617
const calendars = _.get(calListResp, "data.items");
1718
if (calendars) {
1819
const calendarIds = calendars.map((item) => {
19-
return { value: item.id, label: item.summary };
20+
return {
21+
value: item.id,
22+
label: item.summary,
23+
};
2024
});
2125
return calendarIds;
2226
}
@@ -50,10 +54,13 @@ module.exports = {
5054
if (Array.isArray(events)) {
5155
for (const event of events) {
5256
const eventStart = _.get(event, "start.dateTime");
53-
start = new Date(eventStart);
57+
const start = new Date(eventStart);
5458
const msFromStart = start.getTime() - now.getTime();
5559
if (eventStart && msFromStart > 0 && msFromStart < intervalMs) {
56-
const { summary, id } = event;
60+
const {
61+
summary,
62+
id,
63+
} = event;
5764
this.$emit(event, {
5865
summary,
5966
id,

components/google_calendar/sources/new-calendar/new-calendar.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
key: "google_calendar-new-calendar",
66
name: "New Calendar",
77
description: "Emit an event when a calendar is created.",
8-
version: "0.0.1",
8+
version: "0.0.2",
9+
type: "source",
910
props: {
1011
db: "$.service.db",
1112
googleCalendar,
@@ -28,7 +29,7 @@ module.exports = {
2829
this.db.set("calendarIds", []);
2930
},
3031
},
31-
async run(event) {
32+
async run() {
3233
const previousCalendarIds = this.db.get("calendarIds") || [];
3334

3435
const calListResp = await this.googleCalendar.calendarList();
@@ -38,7 +39,10 @@ module.exports = {
3839
for (const calendar of calendars) {
3940
currentCalendarIds.push(calendar.id);
4041
if (!previousCalendarIds.includes(calendar.id)) {
41-
const { summary, id } = calendar;
42+
const {
43+
summary,
44+
id,
45+
} = calendar;
4246
this.$emit(calendar, {
4347
summary,
4448
id,

components/google_calendar/sources/new-event/new-event.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
key: "google_calendar-new-event",
66
name: "New Event",
77
description: "Emits when an event is created",
8-
version: "0.0.1",
8+
version: "0.0.2",
9+
type: "source",
910
dedupe: "unique", // Dedupe events based on the Google Calendar event ID
1011
props: {
1112
googleCalendar,
@@ -16,7 +17,10 @@ module.exports = {
1617
const calendars = _.get(calListResp, "data.items");
1718
if (calendars) {
1819
const calendarIds = calendars.map((item) => {
19-
return { value: item.id, label: item.summary };
20+
return {
21+
value: item.id,
22+
label: item.summary,
23+
};
2024
});
2125
return calendarIds;
2226
}
@@ -50,7 +54,10 @@ module.exports = {
5054
for (const event of events) {
5155
const created = new Date(event.created);
5256
if (created > past && event.status !== "cancelled") {
53-
const { summary, id } = event;
57+
const {
58+
summary,
59+
id,
60+
} = event;
5461
this.$emit(event, {
5562
summary,
5663
id,

components/google_calendar/sources/new-or-updated-event/new-or-updated-event.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
key: "google_calendar-new-or-updated-event",
66
name: "New or Updated Event",
77
description: "Emits when an event is created or updated (except when it's cancelled)",
8-
version: "0.0.1",
8+
version: "0.0.2",
9+
type: "source",
910
dedupe: "unique", // Dedupe events based on the Google Calendar event ID
1011
props: {
1112
googleCalendar,
@@ -16,7 +17,10 @@ module.exports = {
1617
const calendars = _.get(calListResp, "data.items");
1718
if (calendars) {
1819
const calendarIds = calendars.map((item) => {
19-
return { value: item.id, label: item.summary };
20+
return {
21+
value: item.id,
22+
label: item.summary,
23+
};
2024
});
2125
return calendarIds;
2226
}
@@ -49,7 +53,10 @@ module.exports = {
4953
if (Array.isArray(events)) {
5054
for (const event of events) {
5155
if (event.status !== "cancelled") {
52-
const { summary, id } = event;
56+
const {
57+
summary,
58+
id,
59+
} = event;
5360
this.$emit(event, {
5461
summary,
5562
id,

0 commit comments

Comments
 (0)