@pipedream/microsoft_outlook_calendar 0.3.1 → 0.3.2
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.
@@ -1,16 +1,18 @@
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
1
2
|
import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
|
3
|
+
import utils from "../../common/utils.mjs";
|
2
4
|
|
3
5
|
export default {
|
4
6
|
key: "microsoft_outlook_calendar-get-schedule",
|
5
7
|
name: "Get Free/Busy Schedule",
|
6
8
|
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.
|
9
|
+
version: "0.0.3",
|
8
10
|
type: "action",
|
9
11
|
props: {
|
10
12
|
microsoftOutlook,
|
11
13
|
schedules: {
|
12
14
|
type: "string[]",
|
13
|
-
label: "
|
15
|
+
label: "Schedules",
|
14
16
|
description: "A list of emails of users, distribution lists, or resources. For example: `[ \"adelev@contoso.com\" , \"meganb@contoso.com\" ]`",
|
15
17
|
},
|
16
18
|
start: {
|
@@ -48,10 +50,16 @@ export default {
|
|
48
50
|
},
|
49
51
|
},
|
50
52
|
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
|
+
|
51
59
|
const { value } = await this.getSchedule({
|
52
60
|
$,
|
53
61
|
data: {
|
54
|
-
schedules
|
62
|
+
schedules,
|
55
63
|
startTime: {
|
56
64
|
dateTime: this.start,
|
57
65
|
timeZone: this.timeZone,
|
@@ -64,7 +72,7 @@ export default {
|
|
64
72
|
},
|
65
73
|
});
|
66
74
|
|
67
|
-
$.export("$summary", `Successfully retrieved schedules for \`${
|
75
|
+
$.export("$summary", `Successfully retrieved schedules for \`${schedules.join("`, `")}\``);
|
68
76
|
|
69
77
|
return value;
|
70
78
|
},
|
package/common/utils.mjs
ADDED
@@ -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
|
+
};
|