@pipedream/microsoft_outlook 1.0.5 → 1.1.1

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.
@@ -0,0 +1,54 @@
1
+ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2
+ import { ConfigurationError } from "@pipedream/platform";
3
+
4
+ export default {
5
+ key: "microsoft_outlook-add-label-to-email",
6
+ name: "Add Label to Email",
7
+ description: "Adds a label/category to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-update)",
8
+ version: "0.0.2",
9
+ type: "action",
10
+ props: {
11
+ microsoftOutlook,
12
+ messageId: {
13
+ propDefinition: [
14
+ microsoftOutlook,
15
+ "messageId",
16
+ ],
17
+ },
18
+ label: {
19
+ propDefinition: [
20
+ microsoftOutlook,
21
+ "label",
22
+ (c) => ({
23
+ messageId: c.messageId,
24
+ excludeMessageLabels: true,
25
+ }),
26
+ ],
27
+ },
28
+ },
29
+ async run({ $ }) {
30
+ const message = await this.microsoftOutlook.getMessage({
31
+ $,
32
+ messageId: this.messageId,
33
+ });
34
+
35
+ const labels = message?.categories;
36
+
37
+ if (labels.includes(this.label)) {
38
+ throw new ConfigurationError(`Message already contains label "${this.label}".`);
39
+ }
40
+
41
+ const response = await this.microsoftOutlook.updateMessage({
42
+ $,
43
+ messageId: this.messageId,
44
+ data: {
45
+ categories: [
46
+ ...labels,
47
+ this.label,
48
+ ],
49
+ },
50
+ });
51
+ $.export("$summary", "Successfully added label to message.");
52
+ return response;
53
+ },
54
+ };
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-create-contact",
6
- version: "0.0.7",
6
+ version: "0.0.9",
7
7
  name: "Create Contact",
8
8
  description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
9
9
  props: {
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-create-draft-email",
6
- version: "0.0.7",
6
+ version: "0.0.9",
7
7
  name: "Create Draft Email",
8
8
  description: "Create a draft email, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
9
9
  props: {
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-find-contacts",
6
- version: "0.0.7",
6
+ version: "0.0.9",
7
7
  name: "Find Contacts",
8
8
  description: "Finds contacts with given search string",
9
9
  props: {
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-list-contacts",
6
- version: "0.0.7",
6
+ version: "0.0.9",
7
7
  name: "List Contacts",
8
8
  description: "Get a contact collection from the default contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
9
9
  props: {
@@ -0,0 +1,21 @@
1
+ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_outlook-list-labels",
5
+ name: "List Labels",
6
+ 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.2",
8
+ type: "action",
9
+ props: {
10
+ microsoftOutlook,
11
+ },
12
+ async run({ $ }) {
13
+ const { value } = await this.microsoftOutlook.listLabels({
14
+ $,
15
+ });
16
+ $.export("$summary", `Successfully retrieved ${value.length} label${value.length != 1
17
+ ? "s"
18
+ : ""}.`);
19
+ return value;
20
+ },
21
+ };
@@ -0,0 +1,51 @@
1
+ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2
+
3
+ export default {
4
+ key: "microsoft_outlook-remove-label-from-email",
5
+ name: "Remove Label from Email",
6
+ 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.2",
8
+ type: "action",
9
+ props: {
10
+ microsoftOutlook,
11
+ messageId: {
12
+ propDefinition: [
13
+ microsoftOutlook,
14
+ "messageId",
15
+ ],
16
+ },
17
+ label: {
18
+ propDefinition: [
19
+ microsoftOutlook,
20
+ "label",
21
+ (c) => ({
22
+ messageId: c.messageId,
23
+ onlyMessageLabels: true,
24
+ }),
25
+ ],
26
+ description: "The name of the label/category to remove",
27
+ },
28
+ },
29
+ async run({ $ }) {
30
+ const message = await this.microsoftOutlook.getMessage({
31
+ $,
32
+ messageId: this.messageId,
33
+ });
34
+ let labels = message?.categories;
35
+
36
+ const index = labels.indexOf(this.label);
37
+ if (index > -1) {
38
+ labels.splice(index, 1);
39
+ }
40
+
41
+ const response = await this.microsoftOutlook.updateMessage({
42
+ $,
43
+ messageId: this.messageId,
44
+ data: {
45
+ categories: labels,
46
+ },
47
+ });
48
+ $.export("$summary", "Successfully removed label from message.");
49
+ return response;
50
+ },
51
+ };
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-send-email",
6
- version: "0.0.8",
6
+ version: "0.0.10",
7
7
  name: "Send Email",
8
8
  description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
9
9
  props: {
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook-update-contact",
6
- version: "0.0.7",
6
+ version: "0.0.9",
7
7
  name: "Update Contact",
8
8
  description: "Add a contact to the root Contacts folder, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
9
9
  props: {
@@ -100,6 +100,49 @@ export default {
100
100
  type: "object",
101
101
  optional: true,
102
102
  },
103
+ label: {
104
+ type: "string",
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) || [];
123
+ },
124
+ },
125
+ messageId: {
126
+ type: "string",
127
+ label: "Message ID",
128
+ description: "The identifier of the message to update",
129
+ async options({ page }) {
130
+ const limit = 50;
131
+ const { value } = await this.listMessages({
132
+ params: {
133
+ $top: limit,
134
+ $skip: limit * page,
135
+ $orderby: "createdDateTime desc",
136
+ },
137
+ });
138
+ return value?.map(({
139
+ id: value, subject: label,
140
+ }) => ({
141
+ value,
142
+ label,
143
+ })) || [];
144
+ },
145
+ },
103
146
  },
104
147
  methods: {
105
148
  _getUrl(path) {
@@ -286,5 +329,20 @@ export default {
286
329
  ...args,
287
330
  });
288
331
  },
332
+ listLabels(args = {}) {
333
+ return this._makeRequest({
334
+ path: "/me/outlook/masterCategories",
335
+ ...args,
336
+ });
337
+ },
338
+ updateMessage({
339
+ messageId, ...args
340
+ }) {
341
+ return this._makeRequest({
342
+ method: "PATCH",
343
+ path: `/me/messages/${messageId}`,
344
+ ...args,
345
+ });
346
+ },
289
347
  },
290
348
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_outlook",
3
- "version": "1.0.5",
3
+ "version": "1.1.1",
4
4
  "description": "Pipedream Microsoft Outlook Components",
5
5
  "main": "microsoft_outlook.app.mjs",
6
6
  "keywords": [
@@ -12,6 +12,7 @@
12
12
  "homepage": "https://pipedream.com/apps/microsoft_outlook",
13
13
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
14
14
  "dependencies": {
15
+ "@pipedream/platform": "^3.0.3",
15
16
  "axios": "^0.21.1",
16
17
  "js-base64": "^3.7.2",
17
18
  "md5": "^2.3.0",
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_outlook-new-contact",
6
6
  name: "New Contact Event (Instant)",
7
7
  description: "Emit new event when a new Contact is created",
8
- version: "0.0.8",
8
+ version: "0.0.10",
9
9
  type: "source",
10
10
  hooks: {
11
11
  ...common.hooks,
@@ -7,7 +7,7 @@ export default {
7
7
  key: "microsoft_outlook-new-email",
8
8
  name: "New Email Event (Instant)",
9
9
  description: "Emit new event when an email is received in specified folders.",
10
- version: "0.0.11",
10
+ version: "0.0.13",
11
11
  type: "source",
12
12
  dedupe: "unique",
13
13
  props: {