@pipedream/microsoft_outlook 1.7.7 → 1.7.9
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 +1 -1
- package/actions/create-draft-email/create-draft-email.mjs +1 -1
- package/actions/download-attachment/download-attachment.mjs +102 -4
- package/actions/find-contacts/find-contacts.mjs +1 -1
- package/actions/find-email/find-email.mjs +1 -1
- package/actions/find-shared-folder-email/find-shared-folder-email.mjs +1 -1
- package/actions/list-contacts/list-contacts.mjs +1 -1
- package/actions/list-folders/list-folders.mjs +1 -1
- 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 +15 -3
- package/package.json +6 -2
- package/sources/new-attachment-received/new-attachment-received.mjs +1 -1
- package/sources/new-contact/new-contact.mjs +1 -1
- package/sources/new-email/new-email.mjs +1 -1
- package/sources/new-email-in-shared-folder/new-email-in-shared-folder.mjs +1 -1
|
@@ -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.14",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: true,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -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.12",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import mime from "mime-types";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import PDFDocument from "pdfkit";
|
|
5
|
+
import { PassThrough } from "stream";
|
|
6
|
+
import puppeteer from "puppeteer-core";
|
|
7
|
+
import chromium from "@sparticuz/chromium";
|
|
8
|
+
import mammoth from "mammoth";
|
|
9
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
3
10
|
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
|
|
4
11
|
|
|
5
12
|
export default {
|
|
6
13
|
key: "microsoft_outlook-download-attachment",
|
|
7
14
|
name: "Download Attachment",
|
|
8
15
|
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.
|
|
16
|
+
version: "0.0.10",
|
|
10
17
|
annotations: {
|
|
11
18
|
destructiveHint: false,
|
|
12
19
|
openWorldHint: true,
|
|
@@ -36,12 +43,71 @@ export default {
|
|
|
36
43
|
label: "Filename",
|
|
37
44
|
description: "The filename to save the attachment as in the /tmp directory",
|
|
38
45
|
},
|
|
46
|
+
convertToPdf: {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
label: "Convert to PDF",
|
|
49
|
+
description: "Whether to convert the attachment to a PDF file. Supports converting image, text, HTML, and DOCX files.",
|
|
50
|
+
optional: true,
|
|
51
|
+
},
|
|
39
52
|
syncDir: {
|
|
40
53
|
type: "dir",
|
|
41
54
|
accessMode: "write",
|
|
42
55
|
sync: true,
|
|
43
56
|
},
|
|
44
57
|
},
|
|
58
|
+
methods: {
|
|
59
|
+
getAttachmentInfo({
|
|
60
|
+
messageId, attachmentId, ...args
|
|
61
|
+
}) {
|
|
62
|
+
return this.microsoftOutlook._makeRequest({
|
|
63
|
+
path: `/me/messages/${messageId}/attachments/${attachmentId}`,
|
|
64
|
+
...args,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
async imageToPdf(imageBuffer) {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
const doc = new PDFDocument({
|
|
70
|
+
autoFirstPage: false,
|
|
71
|
+
});
|
|
72
|
+
const stream = new PassThrough();
|
|
73
|
+
const chunks = [];
|
|
74
|
+
stream.on("error", reject);
|
|
75
|
+
doc.on("error", reject);
|
|
76
|
+
|
|
77
|
+
stream.on("data", (c) => chunks.push(c));
|
|
78
|
+
stream.on("end", () => resolve(Buffer.concat(chunks)));
|
|
79
|
+
|
|
80
|
+
doc.pipe(stream);
|
|
81
|
+
doc.addPage();
|
|
82
|
+
doc.image(imageBuffer, {
|
|
83
|
+
fit: [
|
|
84
|
+
500,
|
|
85
|
+
700,
|
|
86
|
+
],
|
|
87
|
+
align: "center",
|
|
88
|
+
});
|
|
89
|
+
doc.end();
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
async htmlToPdf(htmlBuffer) {
|
|
93
|
+
const browser = await puppeteer.launch({
|
|
94
|
+
executablePath: await chromium.executablePath(),
|
|
95
|
+
args: chromium.args,
|
|
96
|
+
headless: chromium.headless,
|
|
97
|
+
});
|
|
98
|
+
try {
|
|
99
|
+
const page = await browser.newPage();
|
|
100
|
+
await page.setContent(htmlBuffer.toString("utf8"), {
|
|
101
|
+
waitUntil: "domcontentloaded",
|
|
102
|
+
});
|
|
103
|
+
return await page.pdf({
|
|
104
|
+
format: "A4",
|
|
105
|
+
});
|
|
106
|
+
} finally {
|
|
107
|
+
await browser.close();
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
},
|
|
45
111
|
async run({ $ }) {
|
|
46
112
|
const response = await this.microsoftOutlook.getAttachment({
|
|
47
113
|
$,
|
|
@@ -50,14 +116,46 @@ export default {
|
|
|
50
116
|
responseType: "arraybuffer",
|
|
51
117
|
});
|
|
52
118
|
|
|
119
|
+
let filename = this.filename;
|
|
120
|
+
if (this.convertToPdf) {
|
|
121
|
+
const name = path.parse(filename).name;
|
|
122
|
+
filename = `${name}.pdf`;
|
|
123
|
+
}
|
|
124
|
+
|
|
53
125
|
const rawcontent = response.toString("base64");
|
|
54
|
-
|
|
55
|
-
|
|
126
|
+
let buffer = Buffer.from(rawcontent, "base64");
|
|
127
|
+
|
|
128
|
+
if (this.convertToPdf) {
|
|
129
|
+
const { contentType: mimeType } = await this.getAttachmentInfo({
|
|
130
|
+
$,
|
|
131
|
+
messageId: this.messageId,
|
|
132
|
+
attachmentId: this.attachmentId,
|
|
133
|
+
});
|
|
134
|
+
if (mimeType !== "application/pdf") {
|
|
135
|
+
if (mimeType?.startsWith("image/")) {
|
|
136
|
+
buffer = await this.imageToPdf(buffer);
|
|
137
|
+
} else if (mimeType === "text/html") {
|
|
138
|
+
buffer = await this.htmlToPdf(buffer);
|
|
139
|
+
} else if (mimeType === "text/plain") {
|
|
140
|
+
const textBuffer = Buffer.from(`<pre>${buffer.toString("utf8")}</pre>`, "utf8");
|
|
141
|
+
buffer = await this.htmlToPdf(textBuffer);
|
|
142
|
+
} else if (mimeType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document") {
|
|
143
|
+
const { value: html } = await mammoth.convertToHtml({
|
|
144
|
+
buffer,
|
|
145
|
+
});
|
|
146
|
+
buffer = await this.htmlToPdf(html);
|
|
147
|
+
} else {
|
|
148
|
+
throw new ConfigurationError(`Cannot convert file type: ${mimeType} to PDF`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const downloadedFilepath = `/tmp/${filename}`;
|
|
56
154
|
fs.writeFileSync(downloadedFilepath, buffer);
|
|
57
155
|
const contentType = mime.lookup(downloadedFilepath);
|
|
58
156
|
|
|
59
157
|
return {
|
|
60
|
-
fileName:
|
|
158
|
+
fileName: filename,
|
|
61
159
|
contentType,
|
|
62
160
|
filePath: downloadedFilepath,
|
|
63
161
|
};
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "microsoft_outlook-find-email",
|
|
6
6
|
name: "Find Email",
|
|
7
7
|
description: "Search for an email in Microsoft Outlook. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-messages)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.15",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "microsoft_outlook-find-shared-folder-email",
|
|
6
6
|
name: "Find Shared Folder Email",
|
|
7
7
|
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)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.6",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -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
|
+
version: "0.0.12",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -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.14",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -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.12",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -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.14",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -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.11",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -195,8 +195,19 @@ export default {
|
|
|
195
195
|
type: "string",
|
|
196
196
|
label: "User ID",
|
|
197
197
|
description: "The ID of the user to get messages for",
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
useQuery: true,
|
|
199
|
+
async options({ query }) {
|
|
200
|
+
const args = query
|
|
201
|
+
? {
|
|
202
|
+
params: {
|
|
203
|
+
$search: `"${encodeURIComponent("displayName:" + query)}" OR "${encodeURIComponent("mail:" + query)}" OR "${encodeURIComponent("userPrincipalName:" + query)}"`,
|
|
204
|
+
},
|
|
205
|
+
headers: {
|
|
206
|
+
"ConsistencyLevel": "eventual",
|
|
207
|
+
},
|
|
208
|
+
}
|
|
209
|
+
: {};
|
|
210
|
+
const { value: users } = await this.listUsers(args);
|
|
200
211
|
return users?.map(({
|
|
201
212
|
id: value, displayName, mail,
|
|
202
213
|
}) => ({
|
|
@@ -258,11 +269,12 @@ export default {
|
|
|
258
269
|
_getUrl(path) {
|
|
259
270
|
return `https://graph.microsoft.com/v1.0${path}`;
|
|
260
271
|
},
|
|
261
|
-
_getHeaders() {
|
|
272
|
+
_getHeaders(headers) {
|
|
262
273
|
return {
|
|
263
274
|
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
|
|
264
275
|
"accept": "application/json",
|
|
265
276
|
"Content-Type": "application/json",
|
|
277
|
+
...headers,
|
|
266
278
|
};
|
|
267
279
|
},
|
|
268
280
|
async _makeRequest({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/microsoft_outlook",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"description": "Pipedream Microsoft Outlook Components",
|
|
5
5
|
"main": "microsoft_outlook.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -13,10 +13,14 @@
|
|
|
13
13
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@pipedream/platform": "^3.1.1",
|
|
16
|
+
"@sparticuz/chromium": "^143.0.4",
|
|
16
17
|
"axios": "^0.30.2",
|
|
17
18
|
"js-base64": "^3.7.2",
|
|
19
|
+
"mammoth": "^1.11.0",
|
|
18
20
|
"md5": "^2.3.0",
|
|
19
|
-
"mime-types": "^2.1.35"
|
|
21
|
+
"mime-types": "^2.1.35",
|
|
22
|
+
"pdfkit": "^0.17.2",
|
|
23
|
+
"puppeteer-core": "^24.36.1"
|
|
20
24
|
},
|
|
21
25
|
"publishConfig": {
|
|
22
26
|
"access": "public"
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "microsoft_outlook-new-attachment-received",
|
|
7
7
|
name: "New Attachment Received (Instant)",
|
|
8
8
|
description: "Emit new event when a new email containing one or more attachments arrives in a specified Microsoft Outlook folder.",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.5",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
props: {
|
|
@@ -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.
|
|
10
|
+
version: "0.1.7",
|
|
11
11
|
type: "source",
|
|
12
12
|
dedupe: "unique",
|
|
13
13
|
methods: {
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
key: "microsoft_outlook-new-email-in-shared-folder",
|
|
8
8
|
name: "New Email in Shared Folder Event",
|
|
9
9
|
description: "Emit new event when an email is received in specified shared folders.",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.7",
|
|
11
11
|
type: "source",
|
|
12
12
|
dedupe: "unique",
|
|
13
13
|
props: {
|