@pipedream/microsoft_outlook 1.6.0 → 1.7.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.
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_outlook-add-label-to-email",
6
6
  name: "Add Label to Email",
7
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.9",
8
+ version: "0.0.10",
9
9
  type: "action",
10
10
  props: {
11
11
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-approve-workflow",
5
5
  name: "Approve Workflow",
6
6
  description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
7
- version: "0.0.7",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -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.16",
6
+ version: "0.0.17",
7
7
  name: "Create Contact",
8
8
  description: "Add a contact to the root Contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
9
9
  props: {
@@ -4,7 +4,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
4
4
  export default {
5
5
  type: "action",
6
6
  key: "microsoft_outlook-create-draft-email",
7
- version: "0.0.16",
7
+ version: "0.0.17",
8
8
  name: "Create Draft Email",
9
9
  description: "Create a draft email, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
10
10
  props: {
@@ -6,7 +6,7 @@ export default {
6
6
  key: "microsoft_outlook-download-attachment",
7
7
  name: "Download Attachment",
8
8
  description: "Downloads an attachment to the /tmp directory. [See the documentation](https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http)",
9
- version: "0.0.4",
9
+ version: "0.0.5",
10
10
  type: "action",
11
11
  props: {
12
12
  microsoftOutlook,
@@ -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.16",
6
+ version: "0.0.17",
7
7
  name: "Find Contacts",
8
8
  description: "Finds contacts with the given search string. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
9
9
  props: {
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-find-email",
5
5
  name: "Find Email",
6
6
  description: "Search for an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-messages)",
7
- version: "0.0.10",
7
+ version: "0.0.11",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-find-shared-folder-email",
5
5
  name: "Find Shared Folder Email",
6
6
  description: "Search for an email in a shared folder in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-messages)",
7
- version: "0.0.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -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.16",
6
+ version: "0.0.17",
7
7
  name: "List Contacts",
8
8
  description: "Get a contact collection from the default contacts folder, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-contacts)",
9
9
  props: {
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-list-folders",
5
5
  name: "List Folders",
6
6
  description: "Retrieves a list of all folders in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders)",
7
- version: "0.0.7",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-list-labels",
5
5
  name: "List Labels",
6
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.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-move-email-to-folder",
5
5
  name: "Move Email to Folder",
6
6
  description: "Moves an email to the specified folder in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-move)",
7
- version: "0.0.7",
7
+ version: "0.0.8",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-remove-label-from-email",
5
5
  name: "Remove Label from Email",
6
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.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook-reply-to-email",
5
5
  name: "Reply to Email",
6
6
  description: "Reply to an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/message-reply)",
7
- version: "0.0.6",
7
+ version: "0.0.7",
8
8
  type: "action",
9
9
  props: {
10
10
  microsoftOutlook,
@@ -4,7 +4,7 @@ import microsoftOutlook from "../../microsoft_outlook.app.mjs";
4
4
  export default {
5
5
  type: "action",
6
6
  key: "microsoft_outlook-send-email",
7
- version: "0.0.17",
7
+ version: "0.0.18",
8
8
  name: "Send Email",
9
9
  description: "Send an email to one or multiple recipients, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-sendmail)",
10
10
  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.16",
6
+ version: "0.0.17",
7
7
  name: "Update Contact",
8
8
  description: "Update an existing contact, [See the docs](https://docs.microsoft.com/en-us/graph/api/user-post-contacts)",
9
9
  props: {
@@ -276,8 +276,14 @@ export default {
276
276
  headers: this._getHeaders(headers),
277
277
  ...otherConfig,
278
278
  };
279
-
280
- return axios($ ?? this, config);
279
+ try {
280
+ return await axios($ ?? this, config);
281
+ } catch (error) {
282
+ if (error?.response?.status === 403) {
283
+ throw new Error("Insufficient permissions. Please verify that your Microsoft account has the necessary permissions to perform this operation.");
284
+ }
285
+ throw error;
286
+ }
281
287
  },
282
288
  async createHook({ ...args } = {}) {
283
289
  const response = await this._makeRequest({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_outlook",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Pipedream Microsoft Outlook Components",
5
5
  "main": "microsoft_outlook.app.mjs",
6
6
  "keywords": [
@@ -25,7 +25,7 @@ export default {
25
25
  return;
26
26
  }
27
27
  for (const item of events) {
28
- this.emitEvent(item);
28
+ await this.emitEvent(item);
29
29
  }
30
30
  },
31
31
  async activate() {
@@ -1,13 +1,29 @@
1
1
  import common from "../common/common-new-email.mjs";
2
+ import { Readable } from "stream";
2
3
 
3
4
  export default {
4
5
  ...common,
5
6
  key: "microsoft_outlook-new-attachment-received",
6
7
  name: "New Attachment Received (Instant)",
7
8
  description: "Emit new event when a new email containing one or more attachments arrives in a specified Microsoft Outlook folder.",
8
- version: "0.0.5",
9
+ version: "0.1.1",
9
10
  type: "source",
10
11
  dedupe: "unique",
12
+ props: {
13
+ ...common.props,
14
+ includeLink: {
15
+ label: "Include Link",
16
+ type: "boolean",
17
+ description: "Upload attachment to your File Stash and emit temporary download link to the file. See [the docs](https://pipedream.com/docs/connect/components/files) to learn more about working with files in Pipedream.",
18
+ default: false,
19
+ optional: true,
20
+ },
21
+ dir: {
22
+ type: "dir",
23
+ accessMode: "write",
24
+ optional: true,
25
+ },
26
+ },
11
27
  methods: {
12
28
  ...common.methods,
13
29
  async getSampleEvents({ pageSize }) {
@@ -36,8 +52,48 @@ export default {
36
52
  }
37
53
  return attachments;
38
54
  },
39
- emitEvent(item) {
55
+ async getMessageAttachments(message) {
56
+ const { value: attachments } = await this.microsoftOutlook.listAttachments({
57
+ messageId: message.id,
58
+ });
59
+ if (!attachments?.length) {
60
+ return [];
61
+ }
62
+ return attachments.map((attachment) => ({
63
+ ...attachment,
64
+ messageId: message.id,
65
+ messageSubject: message.subject,
66
+ messageSender: message.sender,
67
+ messageReceivedDateTime: message.receivedDateTime,
68
+ parentFolderId: message.parentFolderId,
69
+ contentBytes: undefined,
70
+ }));
71
+ },
72
+ async stashAttachment(item) {
73
+ const messageAttachment = await this.microsoftOutlook.getAttachment({
74
+ messageId: item.messageId,
75
+ attachmentId: item.id,
76
+ responseType: "arraybuffer",
77
+ });
78
+ const rawcontent = messageAttachment.toString("base64");
79
+ const buffer = Buffer.from(rawcontent, "base64");
80
+ const filepath = `${item.id}/${item.name}`;
81
+ // Upload the attachment to the configured directory (File Stash) so it
82
+ // can be accessed later.
83
+ const file = await this.dir.open(filepath).fromReadableStream(
84
+ Readable.from(buffer),
85
+ item.contentType,
86
+ buffer.length,
87
+ );
88
+ // Return file details and temporary download link:
89
+ // { path, get_url, s3Key, type }
90
+ return await file.withoutPutUrl().withGetUrl();
91
+ },
92
+ async emitEvent(item) {
40
93
  if (this.isRelevant(item)) {
94
+ if (this.includeLink) {
95
+ item.file = await this.stashAttachment(item);
96
+ }
41
97
  this.$emit(item, this.generateMeta(item));
42
98
  }
43
99
  },
@@ -67,7 +123,9 @@ export default {
67
123
  });
68
124
  if (message.hasAttachments) {
69
125
  const attachments = await this.getMessageAttachments(message);
70
- attachments.forEach((item) => this.emitEvent(item));
126
+ for (const item of attachments) {
127
+ await this.emitEvent(item);
128
+ }
71
129
  }
72
130
  } catch {
73
131
  console.log(`Could not fetch message with ID: ${resourceId}`);
@@ -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.17",
8
+ version: "0.0.18",
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.1.1",
10
+ version: "0.1.3",
11
11
  type: "source",
12
12
  dedupe: "unique",
13
13
  methods: {
@@ -6,7 +6,7 @@ export default {
6
6
  key: "microsoft_outlook-new-email-in-shared-folder",
7
7
  name: "New Email in Shared Folder Event",
8
8
  description: "Emit new event when an email is received in specified shared folders.",
9
- version: "0.0.1",
9
+ version: "0.0.2",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  props: {