Skip to content

Commit 7f4b3e7

Browse files
committed
specify custom days for recurring events
1 parent 018a791 commit 7f4b3e7

File tree

5 files changed

+88
-47
lines changed

5 files changed

+88
-47
lines changed

components/google_calendar/actions/common/create-event-common.mjs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,31 @@ export default {
4646
description: "Select a frequency to make this event repeating",
4747
optional: true,
4848
options: Object.keys(constants.REPEAT_FREQUENCIES),
49-
reloadProps: true,
5049
},
5150
repeatInterval: {
5251
type: "integer",
5352
label: "Repeat Interval",
5453
description: "Enter 1 to \"repeat every day\", enter 2 to \"repeat every other day\", etc. Defaults to 1.",
5554
optional: true,
56-
hidden: true,
55+
},
56+
repeatSpecificDays: {
57+
type: "string[]",
58+
label: "Repeat Specific Days",
59+
description: "The event will repeat on these days of the week. Repeat Interval must be `WEEKLY`.",
60+
optional: true,
61+
options: constants.DAYS_OF_WEEK,
5762
},
5863
repeatUntil: {
5964
type: "string",
6065
label: "Repeat Until",
61-
description: "The event will repeat only until this date, if set",
66+
description: "The event will repeat only until this date, if set. Only one of `Repeat Until` or Repeat `How Many Times` may be entered.",
6267
optional: true,
63-
hidden: true,
6468
},
6569
repeatTimes: {
6670
type: "integer",
6771
label: "Repeat How Many Times?",
68-
description: "Limit the number of times this event will occur",
72+
description: "Limit the number of times this event will occur. Only one of `Repeat Until` or Repeat `How Many Times` may be entered.",
6973
optional: true,
70-
hidden: true,
7174
},
7275
}
7376
),
@@ -159,15 +162,27 @@ export default {
159162
repeatInterval,
160163
repeatTimes,
161164
repeatUntil,
165+
repeatSpecificDays,
162166
}) {
167+
if (!repeatFrequency
168+
&& (repeatInterval || repeatTimes || repeatUntil || repeatSpecificDays)
169+
) {
170+
throw new ConfigurationError("`Repeat Frequency` is required when `Repeat Interval`, `Repeat Times`, `Repeat Until`, or `Repeat Specific Days` is entered.");
171+
}
163172
if (!repeatFrequency) {
164173
return;
165174
}
166175
if (repeatTimes && repeatUntil) {
167176
throw new ConfigurationError("Only one of `Repeat Until` or Repeat `How Many Times` may be entered");
168177
}
178+
if (repeatSpecificDays && repeatFrequency !== "WEEKLY") {
179+
throw new ConfigurationError("`Repeat Specific Days` is only for use with `Repeat Frequency` of `WEEKLY`.");
180+
}
169181

170-
let recurrence = `RRULE:FREQ=${repeatFrequency}`;
182+
let recurrence = `RRULE:FREQ=${repeatFrequency}` ;
183+
if (repeatSpecificDays) {
184+
recurrence = `${recurrence};BYDAY=${repeatSpecificDays.join(",")}`;
185+
}
171186
if (repeatInterval) {
172187
recurrence = `${recurrence};INTERVAL=${repeatInterval}`;
173188
}

components/google_calendar/actions/create-event/create-event.mjs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "google_calendar-create-event",
88
name: "Create Event",
99
description: "Create an event in a Google Calendar. [See the documentation](https://developers.google.com/calendar/api/v3/reference/events/insert)",
10-
version: "1.0.1",
10+
version: "1.0.2",
1111
annotations: {
1212
destructiveHint: false,
1313
openWorldHint: true,
@@ -97,33 +97,32 @@ export default {
9797
description: "Select a frequency to make this event repeating",
9898
optional: true,
9999
options: Object.keys(constants.REPEAT_FREQUENCIES),
100-
reloadProps: true,
101100
},
102-
},
103-
async additionalProps() {
104-
const props = {};
105-
const frequency = constants.REPEAT_FREQUENCIES[this.repeatFrequency];
106-
if (frequency) {
107-
props.repeatInterval = {
108-
type: "integer",
109-
label: "Repeat Interval",
110-
description: `Enter 1 to "repeat every ${frequency}", enter 2 to "repeat every other ${frequency}", etc. Defaults to 1.`,
111-
optional: true,
112-
};
113-
props.repeatUntil = {
114-
type: "string",
115-
label: "Repeat Until",
116-
description: "The event will repeat only until this date (format: `yyyy-mm-dd`, e.g., `2025-12-31`)",
117-
optional: true,
118-
};
119-
props.repeatTimes = {
120-
type: "integer",
121-
label: "Repeat How Many Times?",
122-
description: "Limit the number of times this event will occur",
123-
optional: true,
124-
};
125-
}
126-
return props;
101+
repeatInterval: {
102+
type: "integer",
103+
label: "Repeat Interval",
104+
description: "Enter 1 to \"repeat every day\", enter 2 to \"repeat every other day\", etc. Defaults to 1.",
105+
optional: true,
106+
},
107+
repeatSpecificDays: {
108+
type: "string[]",
109+
label: "Repeat Specific Days",
110+
description: "The event will repeat on these days of the week. Repeat Interval must be `WEEKLY`.",
111+
optional: true,
112+
options: constants.DAYS_OF_WEEK,
113+
},
114+
repeatUntil: {
115+
type: "string",
116+
label: "Repeat Until",
117+
description: "The event will repeat only until this date, if set. Only one of `Repeat Until` or Repeat `How Many Times` may be entered.",
118+
optional: true,
119+
},
120+
repeatTimes: {
121+
type: "integer",
122+
label: "Repeat How Many Times?",
123+
description: "Limit the number of times this event will occur. Only one of `Repeat Until` or Repeat `How Many Times` may be entered.",
124+
optional: true,
125+
},
127126
},
128127
methods: {
129128
...createEventCommon.methods,
@@ -136,6 +135,7 @@ export default {
136135
repeatInterval: this.repeatInterval,
137136
repeatTimes: this.repeatTimes,
138137
repeatUntil: this.repeatUntil,
138+
repeatSpecificDays: this.repeatSpecificDays,
139139
});
140140

141141
const trimmedStart = this.eventStartDate?.trim();

components/google_calendar/actions/update-event/update-event.mjs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import googleCalendar from "../../google_calendar.app.mjs";
22
import createEventCommon from "../common/create-event-common.mjs";
3-
import constants from "../../common/constants.mjs";
43

54
export default {
65
key: "google_calendar-update-event",
76
name: "Update Event",
87
description: "Update an event from Google Calendar. [See the documentation](https://googleapis.dev/nodejs/googleapis/latest/calendar/classes/Resource$Events.html#update)",
9-
version: "0.0.14",
8+
version: "0.0.15",
109
annotations: {
1110
destructiveHint: true,
1211
openWorldHint: true,
@@ -46,16 +45,6 @@ export default {
4645
],
4746
},
4847
},
49-
async additionalProps(props) {
50-
if (this.repeatFrequency) {
51-
const frequency = constants.REPEAT_FREQUENCIES[this.repeatFrequency];
52-
props.repeatInterval.description = `Enter 1 to "repeat every ${frequency}", enter 2 to "repeat every other ${frequency}", etc. Defaults to 1.`;
53-
}
54-
props.repeatInterval.hidden = !this.repeatFrequency;
55-
props.repeatUntil.hidden = !this.repeatFrequency;
56-
props.repeatTimes.hidden = !this.repeatFrequency;
57-
return {};
58-
},
5948
methods: {
6049
...createEventCommon.methods,
6150
},
@@ -72,6 +61,7 @@ export default {
7261
repeatInterval: this.repeatInterval,
7362
repeatTimes: this.repeatTimes,
7463
repeatUntil: this.repeatUntil,
64+
repeatSpecificDays: this.repeatSpecificDays,
7565
});
7666

7767
const response = await this.googleCalendar.updateEvent({

components/google_calendar/common/constants.mjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,44 @@ const WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS = 24 * 60 * 60 * 1000;
8989
const WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS =
9090
(WEBHOOK_SUBSCRIPTION_EXPIRATION_TIME_MILLISECONDS * 0.95) / 1000;
9191

92+
const DAYS_OF_WEEK = [
93+
{
94+
label: "Sunday",
95+
value: "SU",
96+
},
97+
{
98+
label: "Monday",
99+
value: "MO",
100+
},
101+
{
102+
label: "Tuesday",
103+
value: "TU",
104+
},
105+
{
106+
label: "Wednesday",
107+
value: "WE",
108+
},
109+
{
110+
label: "Thursday",
111+
value: "TH",
112+
},
113+
{
114+
label: "Friday",
115+
value: "FR",
116+
},
117+
{
118+
label: "Saturday",
119+
value: "SA",
120+
},
121+
{
122+
label: "Weekdays",
123+
value: "MO,TU,WE,TH,FR",
124+
},
125+
];
126+
92127
export default {
93128
API,
94129
REPEAT_FREQUENCIES,
95130
WEBHOOK_SUBSCRIPTION_RENEWAL_SECONDS,
131+
DAYS_OF_WEEK,
96132
};

components/google_calendar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/google_calendar",
3-
"version": "0.8.5",
3+
"version": "0.8.6",
44
"description": "Pipedream Google_calendar Components",
55
"main": "google_calendar.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)