@pipedream/microsoft_outlook 1.4.0 → 1.5.0
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.
- package/actions/add-label-to-email/add-label-to-email.mjs +1 -1
- package/actions/approve-workflow/approve-workflow.mjs +1 -1
- package/actions/create-contact/create-contact.mjs +2 -2
- package/actions/create-draft-email/create-draft-email.mjs +2 -2
- package/actions/download-attachment/download-attachment.mjs +55 -0
- package/actions/find-contacts/find-contacts.mjs +32 -13
- package/actions/find-email/find-email.mjs +21 -12
- package/actions/list-contacts/list-contacts.mjs +24 -8
- package/actions/list-folders/list-folders.mjs +21 -5
- package/actions/list-labels/list-labels.mjs +1 -1
- package/actions/move-email-to-folder/move-email-to-folder.mjs +1 -1
- package/actions/remove-label-from-email/remove-label-from-email.mjs +1 -1
- package/actions/reply-to-email/reply-to-email.mjs +1 -1
- package/actions/send-email/send-email.mjs +1 -1
- package/actions/update-contact/update-contact.mjs +1 -1
- package/microsoft_outlook.app.mjs +93 -10
- package/package.json +1 -1
- package/sources/common/common-new-email.mjs +58 -0
- package/sources/{common.mjs → common/common.mjs} +1 -1
- package/sources/new-attachment-received/new-attachment-received.mjs +96 -0
- package/sources/new-contact/new-contact.mjs +2 -2
- package/sources/new-email/new-email.mjs +2 -52
|
@@ -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.
|
|
8
|
+
version: "0.0.6",
|
|
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
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -3,9 +3,9 @@ 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.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "Create Contact",
|
|
8
|
-
description: "Add a contact to the root Contacts folder, [See the
|
|
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: {
|
|
10
10
|
microsoftOutlook,
|
|
11
11
|
givenName: {
|
|
@@ -3,9 +3,9 @@ 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.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "Create Draft Email",
|
|
8
|
-
description: "Create a draft email, [See the
|
|
8
|
+
description: "Create a draft email, [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-post-messages)",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
11
11
|
recipients: {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import mime from "mime-types";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "microsoft_outlook-download-attachment",
|
|
7
|
+
name: "Download Attachment",
|
|
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.1",
|
|
10
|
+
type: "action",
|
|
11
|
+
props: {
|
|
12
|
+
microsoftOutlook,
|
|
13
|
+
messageId: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
microsoftOutlook,
|
|
16
|
+
"messageId",
|
|
17
|
+
],
|
|
18
|
+
description: "The identifier of the message containing the attachment to download",
|
|
19
|
+
},
|
|
20
|
+
attachmentId: {
|
|
21
|
+
propDefinition: [
|
|
22
|
+
microsoftOutlook,
|
|
23
|
+
"attachmentId",
|
|
24
|
+
(c) => ({
|
|
25
|
+
messageId: c.messageId,
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
filename: {
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Filename",
|
|
32
|
+
description: "The filename to save the attachment as in the /tmp directory",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
async run({ $ }) {
|
|
36
|
+
const response = await this.microsoftOutlook.getAttachment({
|
|
37
|
+
$,
|
|
38
|
+
messageId: this.messageId,
|
|
39
|
+
attachmentId: this.attachmentId,
|
|
40
|
+
responseType: "arraybuffer",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const rawcontent = response.toString("base64");
|
|
44
|
+
const buffer = Buffer.from(rawcontent, "base64");
|
|
45
|
+
const downloadedFilepath = `/tmp/${this.filename}`;
|
|
46
|
+
fs.writeFileSync(downloadedFilepath, buffer);
|
|
47
|
+
const contentType = mime.lookup(downloadedFilepath);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
fileName: this.filename,
|
|
51
|
+
contentType,
|
|
52
|
+
filePath: downloadedFilepath,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
|
@@ -3,9 +3,9 @@ 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.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "Find Contacts",
|
|
8
|
-
description: "Finds contacts with given search string",
|
|
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: {
|
|
10
10
|
microsoftOutlook,
|
|
11
11
|
searchString: {
|
|
@@ -13,21 +13,40 @@ export default {
|
|
|
13
13
|
description: "Provide email address, given name, surname or display name (case sensitive)",
|
|
14
14
|
type: "string",
|
|
15
15
|
},
|
|
16
|
+
maxResults: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
microsoftOutlook,
|
|
19
|
+
"maxResults",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
16
22
|
},
|
|
17
23
|
async run({ $ }) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
c.givenName.includes(this.searchString) ||
|
|
24
|
-
c.surname.includes(this.searchString) ||
|
|
25
|
-
c.emailAddresses.find((e) =>
|
|
26
|
-
e.address == this.searchString ||
|
|
27
|
-
e.name.includes(this.searchString));
|
|
24
|
+
const contacts = this.microsoftOutlook.paginate({
|
|
25
|
+
fn: this.microsoftOutlook.listContacts,
|
|
26
|
+
args: {
|
|
27
|
+
$,
|
|
28
|
+
},
|
|
28
29
|
});
|
|
30
|
+
|
|
31
|
+
const relatedContacts = [];
|
|
32
|
+
for await (const contact of contacts) {
|
|
33
|
+
if (
|
|
34
|
+
contact?.displayName?.includes(this.searchString) ||
|
|
35
|
+
contact?.givenName?.includes(this.searchString) ||
|
|
36
|
+
contact?.surname?.includes(this.searchString) ||
|
|
37
|
+
contact?.emailAddresses?.find(
|
|
38
|
+
(e) => e?.address == this.searchString || e?.name?.includes(this.searchString),
|
|
39
|
+
)
|
|
40
|
+
) {
|
|
41
|
+
relatedContacts.push(contact);
|
|
42
|
+
if (this.maxResults && relatedContacts.length >= this.maxResults) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
29
48
|
// eslint-disable-next-line multiline-ternary
|
|
30
|
-
$.export("$summary", `${relatedContacts.length} contact${relatedContacts.length != 1 ? "s" : ""}
|
|
49
|
+
$.export("$summary", `${relatedContacts.length} matching contact${relatedContacts.length != 1 ? "s" : ""} found`);
|
|
31
50
|
return relatedContacts;
|
|
32
51
|
},
|
|
33
52
|
};
|
|
@@ -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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
@@ -15,23 +15,32 @@ export default {
|
|
|
15
15
|
optional: true,
|
|
16
16
|
},
|
|
17
17
|
maxResults: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
propDefinition: [
|
|
19
|
+
microsoftOutlook,
|
|
20
|
+
"maxResults",
|
|
21
|
+
],
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
async run({ $ }) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const items = this.microsoftOutlook.paginate({
|
|
26
|
+
fn: this.microsoftOutlook.listMessages,
|
|
27
|
+
args: {
|
|
28
|
+
$,
|
|
29
|
+
params: {
|
|
30
|
+
"$filter": this.filter,
|
|
31
|
+
},
|
|
30
32
|
},
|
|
33
|
+
max: this.maxResults,
|
|
31
34
|
});
|
|
32
|
-
|
|
35
|
+
|
|
36
|
+
const emails = [];
|
|
37
|
+
for await (const item of items) {
|
|
38
|
+
emails.push(item);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
$.export("$summary", `Successfully retrieved ${emails.length} message${emails.length != 1
|
|
33
42
|
? "s"
|
|
34
43
|
: ""}.`);
|
|
35
|
-
return
|
|
44
|
+
return emails;
|
|
36
45
|
},
|
|
37
46
|
};
|
|
@@ -3,25 +3,41 @@ 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.
|
|
6
|
+
version: "0.0.13",
|
|
7
7
|
name: "List Contacts",
|
|
8
|
-
description: "Get a contact collection from the default contacts folder, [See the
|
|
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: {
|
|
10
10
|
microsoftOutlook,
|
|
11
11
|
filterAddress: {
|
|
12
|
-
label: "Email
|
|
12
|
+
label: "Email Address",
|
|
13
13
|
description: "If this is given, only contacts with the given address will be retrieved.",
|
|
14
14
|
type: "string",
|
|
15
15
|
optional: true,
|
|
16
16
|
},
|
|
17
|
+
maxResults: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
microsoftOutlook,
|
|
20
|
+
"maxResults",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
17
23
|
},
|
|
18
24
|
async run({ $ }) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
const items = this.microsoftOutlook.paginate({
|
|
26
|
+
fn: this.microsoftOutlook.listContacts,
|
|
27
|
+
args: {
|
|
28
|
+
$,
|
|
29
|
+
filterAddress: this.filterAddress,
|
|
30
|
+
},
|
|
31
|
+
max: this.maxResults,
|
|
22
32
|
});
|
|
33
|
+
|
|
34
|
+
const contacts = [];
|
|
35
|
+
for await (const item of items) {
|
|
36
|
+
contacts.push(item);
|
|
37
|
+
}
|
|
38
|
+
|
|
23
39
|
// eslint-disable-next-line multiline-ternary
|
|
24
|
-
$.export("$summary", `${
|
|
25
|
-
return
|
|
40
|
+
$.export("$summary", `${contacts.length} contact${contacts.length != 1 ? "s" : ""} retrieved.`);
|
|
41
|
+
return contacts;
|
|
26
42
|
},
|
|
27
43
|
};
|
|
@@ -4,18 +4,34 @@ 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
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
microsoftOutlook,
|
|
11
|
+
maxResults: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
microsoftOutlook,
|
|
14
|
+
"maxResults",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
11
17
|
},
|
|
12
18
|
async run({ $ }) {
|
|
13
|
-
const
|
|
14
|
-
|
|
19
|
+
const items = this.microsoftOutlook.paginate({
|
|
20
|
+
fn: this.microsoftOutlook.listFolders,
|
|
21
|
+
args: {
|
|
22
|
+
$,
|
|
23
|
+
},
|
|
24
|
+
max: this.maxResults,
|
|
15
25
|
});
|
|
16
|
-
|
|
26
|
+
|
|
27
|
+
const folders = [];
|
|
28
|
+
for await (const item of items) {
|
|
29
|
+
folders.push(item);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
$.export("$summary", `Successfully retrieved ${folders.length} folder${folders.length != 1
|
|
17
33
|
? "s"
|
|
18
34
|
: ""}.`);
|
|
19
|
-
return
|
|
35
|
+
return folders;
|
|
20
36
|
},
|
|
21
37
|
};
|
|
@@ -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.
|
|
7
|
+
version: "0.0.6",
|
|
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
|
+
version: "0.0.4",
|
|
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.
|
|
7
|
+
version: "0.0.6",
|
|
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.
|
|
7
|
+
version: "0.0.3",
|
|
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-send-email",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.14",
|
|
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.
|
|
6
|
+
version: "0.0.13",
|
|
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: {
|
|
@@ -3,6 +3,7 @@ import fs from "fs";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { encode } from "js-base64";
|
|
5
5
|
import mime from "mime-types";
|
|
6
|
+
const DEFAULT_LIMIT = 50;
|
|
6
7
|
|
|
7
8
|
export default {
|
|
8
9
|
type: "app",
|
|
@@ -62,8 +63,14 @@ export default {
|
|
|
62
63
|
label: "Contact",
|
|
63
64
|
description: "The contact to be updated",
|
|
64
65
|
type: "string",
|
|
65
|
-
async options() {
|
|
66
|
-
const
|
|
66
|
+
async options({ page }) {
|
|
67
|
+
const limit = DEFAULT_LIMIT;
|
|
68
|
+
const contactResponse = await this.listContacts({
|
|
69
|
+
params: {
|
|
70
|
+
$top: limit,
|
|
71
|
+
$skip: limit * page,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
67
74
|
return contactResponse.value.map((co) => ({
|
|
68
75
|
label: co.displayName,
|
|
69
76
|
value: co.id,
|
|
@@ -127,7 +134,7 @@ export default {
|
|
|
127
134
|
label: "Message ID",
|
|
128
135
|
description: "The identifier of the message to update",
|
|
129
136
|
async options({ page }) {
|
|
130
|
-
const limit =
|
|
137
|
+
const limit = DEFAULT_LIMIT;
|
|
131
138
|
const { value } = await this.listMessages({
|
|
132
139
|
params: {
|
|
133
140
|
$top: limit,
|
|
@@ -147,8 +154,14 @@ export default {
|
|
|
147
154
|
type: "string[]",
|
|
148
155
|
label: "Folder IDs to Monitor",
|
|
149
156
|
description: "Specify the folder IDs or names in Outlook that you want to monitor for new emails. Leave empty to monitor all folders (excluding \"Sent Items\" and \"Drafts\").",
|
|
150
|
-
async options() {
|
|
151
|
-
const
|
|
157
|
+
async options({ page }) {
|
|
158
|
+
const limit = DEFAULT_LIMIT;
|
|
159
|
+
const { value: folders } = await this.listFolders({
|
|
160
|
+
params: {
|
|
161
|
+
$top: limit,
|
|
162
|
+
$skip: limit * page,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
152
165
|
return folders?.map(({
|
|
153
166
|
id: value, displayName: label,
|
|
154
167
|
}) => ({
|
|
@@ -157,6 +170,36 @@ export default {
|
|
|
157
170
|
})) || [];
|
|
158
171
|
},
|
|
159
172
|
},
|
|
173
|
+
attachmentId: {
|
|
174
|
+
type: "string",
|
|
175
|
+
label: "Attachment ID",
|
|
176
|
+
description: "The identifier of the attachment to download",
|
|
177
|
+
async options({
|
|
178
|
+
messageId, page,
|
|
179
|
+
}) {
|
|
180
|
+
const limit = DEFAULT_LIMIT;
|
|
181
|
+
const { value: attachments } = await this.listAttachments({
|
|
182
|
+
messageId,
|
|
183
|
+
params: {
|
|
184
|
+
$top: limit,
|
|
185
|
+
$skip: limit * page,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
return attachments?.map(({
|
|
189
|
+
id: value, name: label,
|
|
190
|
+
}) => ({
|
|
191
|
+
value,
|
|
192
|
+
label,
|
|
193
|
+
})) || [];
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
maxResults: {
|
|
197
|
+
type: "integer",
|
|
198
|
+
label: "Max Results",
|
|
199
|
+
description: "The maximum number of results to return",
|
|
200
|
+
default: 100,
|
|
201
|
+
optional: true,
|
|
202
|
+
},
|
|
160
203
|
},
|
|
161
204
|
methods: {
|
|
162
205
|
_getUrl(path) {
|
|
@@ -304,16 +347,15 @@ export default {
|
|
|
304
347
|
filterAddress,
|
|
305
348
|
...args
|
|
306
349
|
} = {}) {
|
|
307
|
-
|
|
350
|
+
args.params = {
|
|
351
|
+
...args?.params,
|
|
352
|
+
};
|
|
308
353
|
if (filterAddress) {
|
|
309
|
-
|
|
310
|
-
"$filter": `emailAddresses/any(a:a/address eq '${filterAddress}')`,
|
|
311
|
-
};
|
|
354
|
+
args.params["$filter"] = `emailAddresses/any(a:a/address eq '${filterAddress}')`;
|
|
312
355
|
}
|
|
313
356
|
return await this._makeRequest({
|
|
314
357
|
method: "GET",
|
|
315
358
|
path: "/me/contacts",
|
|
316
|
-
...paramsContainer,
|
|
317
359
|
...args,
|
|
318
360
|
});
|
|
319
361
|
},
|
|
@@ -384,5 +426,46 @@ export default {
|
|
|
384
426
|
...args,
|
|
385
427
|
});
|
|
386
428
|
},
|
|
429
|
+
getAttachment({
|
|
430
|
+
messageId, attachmentId, ...args
|
|
431
|
+
}) {
|
|
432
|
+
return this._makeRequest({
|
|
433
|
+
path: `/me/messages/${messageId}/attachments/${attachmentId}/$value`,
|
|
434
|
+
...args,
|
|
435
|
+
});
|
|
436
|
+
},
|
|
437
|
+
listAttachments({
|
|
438
|
+
messageId, ...args
|
|
439
|
+
}) {
|
|
440
|
+
return this._makeRequest({
|
|
441
|
+
path: `/me/messages/${messageId}/attachments`,
|
|
442
|
+
...args,
|
|
443
|
+
});
|
|
444
|
+
},
|
|
445
|
+
async *paginate({
|
|
446
|
+
fn, args = {}, max,
|
|
447
|
+
}) {
|
|
448
|
+
const limit = DEFAULT_LIMIT;
|
|
449
|
+
args = {
|
|
450
|
+
...args,
|
|
451
|
+
params: {
|
|
452
|
+
...args?.params,
|
|
453
|
+
$top: limit,
|
|
454
|
+
$skip: 0,
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
let total, count = 0;
|
|
458
|
+
do {
|
|
459
|
+
const { value } = await fn(args);
|
|
460
|
+
for (const item of value) {
|
|
461
|
+
yield item;
|
|
462
|
+
if (max && ++count >= max) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
total = value?.length;
|
|
467
|
+
args.params["$skip"] += limit;
|
|
468
|
+
} while (total);
|
|
469
|
+
},
|
|
387
470
|
},
|
|
388
471
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import common from "./common.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
props: {
|
|
6
|
+
...common.props,
|
|
7
|
+
folderIds: {
|
|
8
|
+
propDefinition: [
|
|
9
|
+
common.props.microsoftOutlook,
|
|
10
|
+
"folderIds",
|
|
11
|
+
],
|
|
12
|
+
optional: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
hooks: {
|
|
16
|
+
...common.hooks,
|
|
17
|
+
async deploy() {
|
|
18
|
+
this.db.set("sentItemFolderId", await this.getFolderIdByName("Sent Items"));
|
|
19
|
+
this.db.set("draftsFolderId", await this.getFolderIdByName("Drafts"));
|
|
20
|
+
|
|
21
|
+
const events = await this.getSampleEvents({
|
|
22
|
+
pageSize: 25,
|
|
23
|
+
});
|
|
24
|
+
if (!events || events.length == 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const item of events) {
|
|
28
|
+
this.emitEvent(item);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async activate() {
|
|
32
|
+
await this.activate({
|
|
33
|
+
changeType: "created",
|
|
34
|
+
resource: "/me/messages",
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
async deactivate() {
|
|
38
|
+
await this.deactivate();
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
...common.methods,
|
|
43
|
+
async getFolderIdByName(name) {
|
|
44
|
+
const { value: folders } = await this.microsoftOutlook.listFolders();
|
|
45
|
+
const folder = folders.find(({ displayName }) => displayName === name);
|
|
46
|
+
return folder?.id;
|
|
47
|
+
},
|
|
48
|
+
isRelevant(item) {
|
|
49
|
+
if (this.folderIds?.length) {
|
|
50
|
+
return this.folderIds.includes(item.parentFolderId);
|
|
51
|
+
}
|
|
52
|
+
// if no folderIds are specified, filter out items in Sent Items & Drafts
|
|
53
|
+
const sentItemFolderId = this.db.get("sentItemFolderId");
|
|
54
|
+
const draftsFolderId = this.db.get("draftsFolderId");
|
|
55
|
+
return item.parentFolderId !== sentItemFolderId && item.parentFolderId !== draftsFolderId;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import common from "../common/common-new-email.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "microsoft_outlook-new-attachment-received",
|
|
6
|
+
name: "New Attachment Received (Instant)",
|
|
7
|
+
description: "Emit new event when a new email containing one or more attachments arrives in a specified Microsoft Outlook folder.",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
methods: {
|
|
12
|
+
...common.methods,
|
|
13
|
+
async getSampleEvents({ pageSize }) {
|
|
14
|
+
const folders = this.folderIds?.length
|
|
15
|
+
? this.folderIds.map((id) => `/me/mailFolders/${id}/messages`)
|
|
16
|
+
: [
|
|
17
|
+
"/me/messages",
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const messagesWithAttachments = [];
|
|
21
|
+
for (const folder of folders) {
|
|
22
|
+
const { value: messages } = await this.microsoftOutlook.listMessages({
|
|
23
|
+
resource: folder,
|
|
24
|
+
params: {
|
|
25
|
+
$top: pageSize,
|
|
26
|
+
$filter: "hasAttachments eq true",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
messagesWithAttachments.push(...messages);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const attachments = [];
|
|
33
|
+
for (const message of messagesWithAttachments) {
|
|
34
|
+
const messageAttachments = await this.getMessageAttachments(message);
|
|
35
|
+
attachments.push(...messageAttachments);
|
|
36
|
+
}
|
|
37
|
+
return attachments;
|
|
38
|
+
},
|
|
39
|
+
async getMessageAttachments(message) {
|
|
40
|
+
const { value: attachments } = await this.microsoftOutlook.listAttachments({
|
|
41
|
+
messageId: message.id,
|
|
42
|
+
});
|
|
43
|
+
if (!attachments?.length) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return attachments.map((attachment) => ({
|
|
47
|
+
...attachment,
|
|
48
|
+
messageId: message.id,
|
|
49
|
+
messageSubject: message.subject,
|
|
50
|
+
messageSender: message.sender,
|
|
51
|
+
messageReceivedDateTime: message.receivedDateTime,
|
|
52
|
+
parentFolderId: message.parentFolderId,
|
|
53
|
+
contentBytes: undefined,
|
|
54
|
+
}));
|
|
55
|
+
},
|
|
56
|
+
emitEvent(item) {
|
|
57
|
+
if (this.isRelevant(item)) {
|
|
58
|
+
this.$emit(item, this.generateMeta(item));
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
generateMeta(item) {
|
|
62
|
+
return {
|
|
63
|
+
id: item.contentId,
|
|
64
|
+
summary: `New attachment ${item.name}`,
|
|
65
|
+
ts: Date.parse(item.messageReceivedDateTime),
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
async run(event) {
|
|
70
|
+
const folders = this.folderIds?.length
|
|
71
|
+
? this.folderIds.map((id) => `/me/mailFolders/${id}/messages`)
|
|
72
|
+
: [
|
|
73
|
+
"/me/messages",
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
for (const folder of folders) {
|
|
77
|
+
await this.run({
|
|
78
|
+
event,
|
|
79
|
+
emitFn: async ({ resourceId } = {}) => {
|
|
80
|
+
try {
|
|
81
|
+
const message = await this.microsoftOutlook.getMessage({
|
|
82
|
+
resource: folder,
|
|
83
|
+
messageId: resourceId,
|
|
84
|
+
});
|
|
85
|
+
if (message.hasAttachments) {
|
|
86
|
+
const attachments = await this.getMessageAttachments(message);
|
|
87
|
+
attachments.forEach((item) => this.emitEvent(item));
|
|
88
|
+
}
|
|
89
|
+
} catch {
|
|
90
|
+
console.log(`Could not fetch message with ID: ${resourceId}`);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
...common,
|
|
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
|
+
version: "0.0.14",
|
|
9
9
|
type: "source",
|
|
10
10
|
hooks: {
|
|
11
11
|
...common.hooks,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
1
|
+
import common from "../common/common-new-email.mjs";
|
|
2
2
|
import md5 from "md5";
|
|
3
3
|
import sampleEmit from "./test-event.mjs";
|
|
4
4
|
|
|
@@ -7,52 +7,11 @@ 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.
|
|
10
|
+
version: "0.0.17",
|
|
11
11
|
type: "source",
|
|
12
12
|
dedupe: "unique",
|
|
13
|
-
props: {
|
|
14
|
-
...common.props,
|
|
15
|
-
folderIds: {
|
|
16
|
-
propDefinition: [
|
|
17
|
-
common.props.microsoftOutlook,
|
|
18
|
-
"folderIds",
|
|
19
|
-
],
|
|
20
|
-
optional: true,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
hooks: {
|
|
24
|
-
...common.hooks,
|
|
25
|
-
async deploy() {
|
|
26
|
-
this.db.set("sentItemFolderId", await this.getFolderIdByName("Sent Items"));
|
|
27
|
-
this.db.set("draftsFolderId", await this.getFolderIdByName("Drafts"));
|
|
28
|
-
|
|
29
|
-
const events = await this.getSampleEvents({
|
|
30
|
-
pageSize: 25,
|
|
31
|
-
});
|
|
32
|
-
if (!events || events.length == 0) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
for (const item of events) {
|
|
36
|
-
this.emitEvent(item);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
async activate() {
|
|
40
|
-
await this.activate({
|
|
41
|
-
changeType: "created",
|
|
42
|
-
resource: "/me/messages",
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
async deactivate() {
|
|
46
|
-
await this.deactivate();
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
13
|
methods: {
|
|
50
14
|
...common.methods,
|
|
51
|
-
async getFolderIdByName(name) {
|
|
52
|
-
const { value: folders } = await this.microsoftOutlook.listFolders();
|
|
53
|
-
const folder = folders.find(({ displayName }) => displayName === name);
|
|
54
|
-
return folder?.id;
|
|
55
|
-
},
|
|
56
15
|
async getSampleEvents({ pageSize }) {
|
|
57
16
|
const folders = this.folderIds?.length
|
|
58
17
|
? this.folderIds.map((id) => `/me/mailFolders/${id}/messages`)
|
|
@@ -73,15 +32,6 @@ export default {
|
|
|
73
32
|
}
|
|
74
33
|
return results;
|
|
75
34
|
},
|
|
76
|
-
isRelevant(item) {
|
|
77
|
-
if (this.folderIds?.length) {
|
|
78
|
-
return this.folderIds.includes(item.parentFolderId);
|
|
79
|
-
}
|
|
80
|
-
// if no folderIds are specified, filter out items in Sent Items & Drafts
|
|
81
|
-
const sentItemFolderId = this.db.get("sentItemFolderId");
|
|
82
|
-
const draftsFolderId = this.db.get("draftsFolderId");
|
|
83
|
-
return item.parentFolderId !== sentItemFolderId && item.parentFolderId !== draftsFolderId;
|
|
84
|
-
},
|
|
85
35
|
emitEvent(item) {
|
|
86
36
|
if (this.isRelevant(item)) {
|
|
87
37
|
this.$emit(
|