Skip to content

Commit ea6d76b

Browse files
authored
[FEATURE] Microsoft Components (#15489)
* microsoft_outlook updates * microsoft_outlook_calendar updates * pnpm-lock.yaml
1 parent d319f39 commit ea6d76b

File tree

16 files changed

+60
-56
lines changed

16 files changed

+60
-56
lines changed

components/microsoft_outlook/actions/add-label-to-email/add-label-to-email.mjs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
23

34
export default {
45
key: "microsoft_outlook-add-label-to-email",
56
name: "Add Label to Email",
67
description: "Adds a label/category to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
7-
version: "0.0.1",
8+
version: "0.0.2",
89
type: "action",
910
props: {
1011
microsoftOutlook,
@@ -14,10 +15,14 @@ export default {
1415
"messageId",
1516
],
1617
},
17-
labelId: {
18+
label: {
1819
propDefinition: [
1920
microsoftOutlook,
20-
"labelId",
21+
"label",
22+
(c) => ({
23+
messageId: c.messageId,
24+
excludeMessageLabels: true,
25+
}),
2126
],
2227
},
2328
},
@@ -29,13 +34,17 @@ export default {
2934

3035
const labels = message?.categories;
3136

37+
if (labels.includes(this.label)) {
38+
throw new ConfigurationError(`Message already contains label "${this.label}".`);
39+
}
40+
3241
const response = await this.microsoftOutlook.updateMessage({
3342
$,
3443
messageId: this.messageId,
3544
data: {
3645
categories: [
3746
...labels,
38-
this.labelId,
47+
this.label,
3948
],
4049
},
4150
});

components/microsoft_outlook/actions/create-contact/create-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-create-contact",
6-
version: "0.0.8",
6+
version: "0.0.9",
77
name: "Create Contact",
88
description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
99
props: {

components/microsoft_outlook/actions/create-draft-email/create-draft-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-create-draft-email",
6-
version: "0.0.8",
6+
version: "0.0.9",
77
name: "Create Draft Email",
88
description: "Create a draft email, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
99
props: {

components/microsoft_outlook/actions/find-contacts/find-contacts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-find-contacts",
6-
version: "0.0.8",
6+
version: "0.0.9",
77
name: "Find Contacts",
88
description: "Finds contacts with given search string",
99
props: {

components/microsoft_outlook/actions/list-contacts/list-contacts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-list-contacts",
6-
version: "0.0.8",
6+
version: "0.0.9",
77
name: "List Contacts",
88
description: "Get a contact collection from the default contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
99
props: {

components/microsoft_outlook/actions/list-labels/list-labels.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-list-labels",
55
name: "List Labels",
66
description: "Get all the labels/categories that have been defined for a user. [See the documentation](https://learn.microsoft.com/en-us/graph/api/outlookuser-list-mastercategories)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
microsoftOutlook,

components/microsoft_outlook/actions/remove-label-from-email/remove-label-from-email.mjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "microsoft_outlook-remove-label-from-email",
55
name: "Remove Label from Email",
66
description: "Removes a label/category from an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
microsoftOutlook,
@@ -14,12 +14,16 @@ export default {
1414
"messageId",
1515
],
1616
},
17-
labelId: {
17+
label: {
1818
propDefinition: [
1919
microsoftOutlook,
20-
"labelId",
20+
"label",
21+
(c) => ({
22+
messageId: c.messageId,
23+
onlyMessageLabels: true,
24+
}),
2125
],
22-
description: "The identifier of the label/category to remove",
26+
description: "The name of the label/category to remove",
2327
},
2428
},
2529
async run({ $ }) {
@@ -29,7 +33,7 @@ export default {
2933
});
3034
let labels = message?.categories;
3135

32-
const index = labels.indexOf(this.labelId);
36+
const index = labels.indexOf(this.label);
3337
if (index > -1) {
3438
labels.splice(index, 1);
3539
}

components/microsoft_outlook/actions/send-email/send-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-send-email",
6-
version: "0.0.9",
6+
version: "0.0.10",
77
name: "Send Email",
88
description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
99
props: {

components/microsoft_outlook/actions/update-contact/update-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
33
export default {
44
type: "action",
55
key: "microsoft_outlook-update-contact",
6-
version: "0.0.8",
6+
version: "0.0.9",
77
name: "Update Contact",
88
description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
99
props: {

components/microsoft_outlook/microsoft_outlook.app.mjs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,26 @@ export default {
100100
type: "object",
101101
optional: true,
102102
},
103-
labelId: {
103+
label: {
104104
type: "string",
105-
label: "Label ID",
106-
description: "The identifier of the label/category to add",
107-
async options() {
108-
const { value: labels } = await this.listLabels();
109-
return labels?.map(({
110-
id: value, displayName: label,
111-
}) => ({
112-
value,
113-
label,
114-
})) || [];
105+
label: "Label",
106+
description: "The name of the label/category to add",
107+
async options({
108+
messageId, excludeMessageLabels, onlyMessageLabels,
109+
}) {
110+
const { value } = await this.listLabels();
111+
let labels = value;
112+
if (messageId) {
113+
const { categories } = await this.getMessage({
114+
messageId,
115+
});
116+
labels = excludeMessageLabels
117+
? labels.filter(({ displayName }) => !categories.includes(displayName))
118+
: onlyMessageLabels
119+
? labels.filter(({ displayName }) => categories.includes(displayName))
120+
: labels;
121+
}
122+
return labels?.map(({ displayName }) => displayName) || [];
115123
},
116124
},
117125
messageId: {

0 commit comments

Comments
 (0)