Skip to content

Commit 0336a73

Browse files
committed
[BUG] Microsoft Calendar using Get Busy/Free action throwing error
1 parent 5a3f4e5 commit 0336a73

File tree

4 files changed

+67
-31
lines changed

4 files changed

+67
-31
lines changed

components/microsoft_outlook_calendar/actions/get-schedule/get-schedule.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
3+
import utils from "../../common/utils.mjs";
24

35
export default {
46
key: "microsoft_outlook_calendar-get-schedule",
57
name: "Get Free/Busy Schedule",
68
description: "Get the free/busy availability information for a collection of users, distributions lists, or resources (rooms or equipment) for a specified time period. [See the documentation](https://learn.microsoft.com/en-us/graph/api/calendar-getschedule)",
7-
version: "0.0.2",
9+
version: "0.0.3",
810
type: "action",
911
props: {
1012
microsoftOutlook,
1113
schedules: {
1214
type: "string[]",
13-
label: "Emails",
15+
label: "Schedules",
1416
description: "A list of emails of users, distribution lists, or resources. For example: `[ \"[email protected]\" , \"[email protected]\" ]`",
1517
},
1618
start: {
@@ -48,10 +50,16 @@ export default {
4850
},
4951
},
5052
async run({ $ }) {
53+
if (this.schedules === null || this.schedules === undefined || this.schedules?.length === 0) {
54+
throw new ConfigurationError("The **Schedules** property is required");
55+
}
56+
57+
const schedules = utils.parseArray(this.schedules);
58+
5159
const { value } = await this.getSchedule({
5260
$,
5361
data: {
54-
schedules: this.schedules,
62+
schedules,
5563
startTime: {
5664
dateTime: this.start,
5765
timeZone: this.timeZone,
@@ -64,7 +72,7 @@ export default {
6472
},
6573
});
6674

67-
$.export("$summary", `Successfully retrieved schedules for \`${this.schedules.join("`, `")}\``);
75+
$.export("$summary", `Successfully retrieved schedules for \`${schedules.join("`, `")}\``);
6876

6977
return value;
7078
},
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export default {
2+
parseArray(input) {
3+
if (!input) {
4+
return [];
5+
}
6+
7+
if (typeof input === "string") {
8+
try {
9+
// Try to parse as JSON array first
10+
const parsed = JSON.parse(input);
11+
return Array.isArray(parsed)
12+
? parsed.map((item) => String(item))
13+
: [
14+
String(input),
15+
];
16+
} catch {
17+
// If JSON parsing fails, treat as single string
18+
return [
19+
input,
20+
];
21+
}
22+
}
23+
24+
if (Array.isArray(input)) {
25+
return input.map((item) => String(item));
26+
}
27+
28+
if (typeof input === "object") {
29+
// Convert object to array of its values as strings
30+
return Object.values(input).map((item) => String(item));
31+
}
32+
33+
// For any other type, convert to string and wrap in array
34+
return [
35+
String(input),
36+
];
37+
},
38+
};

components/microsoft_outlook_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/microsoft_outlook_calendar",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Pipedream Microsoft Outlook Calendar Components",
55
"main": "microsoft_outlook_calendar.app.mjs",
66
"keywords": [

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)