Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { ConfigurationError } from "@pipedream/platform";
import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "microsoft_outlook_calendar-get-schedule",
name: "Get Free/Busy Schedule",
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)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
microsoftOutlook,
schedules: {
type: "string[]",
label: "Emails",
label: "Schedules",
description: "A list of emails of users, distribution lists, or resources. For example: `[ \"[email protected]\" , \"[email protected]\" ]`",
},
start: {
Expand Down Expand Up @@ -48,10 +50,16 @@ export default {
},
},
async run({ $ }) {
if (this.schedules === null || this.schedules === undefined || this.schedules?.length === 0) {
throw new ConfigurationError("The **Schedules** property is required");
}

const schedules = utils.parseArray(this.schedules);

const { value } = await this.getSchedule({
$,
data: {
schedules: this.schedules,
schedules,
startTime: {
dateTime: this.start,
timeZone: this.timeZone,
Expand All @@ -64,7 +72,7 @@ export default {
},
});

$.export("$summary", `Successfully retrieved schedules for \`${this.schedules.join("`, `")}\``);
$.export("$summary", `Successfully retrieved schedules for \`${schedules.join("`, `")}\``);

return value;
},
Expand Down
38 changes: 38 additions & 0 deletions components/microsoft_outlook_calendar/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export default {
parseArray(input) {
if (!input) {
return [];
}

if (typeof input === "string") {
try {
// Try to parse as JSON array first
const parsed = JSON.parse(input);
return Array.isArray(parsed)
? parsed.map((item) => String(item))
: [
String(input),
];
} catch {
// If JSON parsing fails, treat as single string
return [
input,
];
}
}

if (Array.isArray(input)) {
return input.map((item) => String(item));
}

if (typeof input === "object") {
// Convert object to array of its values as strings
return Object.values(input).map((item) => String(item));
}

// For any other type, convert to string and wrap in array
return [
String(input),
];
},
};
2 changes: 1 addition & 1 deletion components/microsoft_outlook_calendar/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/microsoft_outlook_calendar",
"version": "0.3.1",
"version": "0.3.2",
"description": "Pipedream Microsoft Outlook Calendar Components",
"main": "microsoft_outlook_calendar.app.mjs",
"keywords": [
Expand Down
42 changes: 16 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading