@activepieces/piece-microsoft-outlook 0.0.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.
- package/README.md +7 -0
- package/package.json +40 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +34 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/download-email-attachment.d.ts +3 -0
- package/src/lib/actions/download-email-attachment.js +44 -0
- package/src/lib/actions/download-email-attachment.js.map +1 -0
- package/src/lib/actions/send-email.d.ts +9 -0
- package/src/lib/actions/send-email.js +111 -0
- package/src/lib/actions/send-email.js.map +1 -0
- package/src/lib/common/auth.d.ts +1 -0
- package/src/lib/common/auth.js +28 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/triggers/new-email.d.ts +2 -0
- package/src/lib/triggers/new-email.js +87 -0
- package/src/lib/triggers/new-email.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-microsoft-outlook",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@ai-sdk/anthropic": "1.2.12",
|
|
6
|
+
"@ai-sdk/openai": "1.3.22",
|
|
7
|
+
"@ai-sdk/replicate": "0.2.8",
|
|
8
|
+
"@microsoft/microsoft-graph-client": "3.0.7",
|
|
9
|
+
"@microsoft/microsoft-graph-types": "2.40.0",
|
|
10
|
+
"@sinclair/typebox": "0.34.11",
|
|
11
|
+
"ai": "4.3.16",
|
|
12
|
+
"axios": "1.8.3",
|
|
13
|
+
"axios-retry": "4.4.1",
|
|
14
|
+
"dayjs": "1.11.9",
|
|
15
|
+
"deepmerge-ts": "7.1.0",
|
|
16
|
+
"fast-glob": "3.3.3",
|
|
17
|
+
"mime-types": "2.1.35",
|
|
18
|
+
"nanoid": "3.3.8",
|
|
19
|
+
"semver": "7.6.0",
|
|
20
|
+
"zod": "3.25.48",
|
|
21
|
+
"@activepieces/pieces-common": "0.5.0",
|
|
22
|
+
"@activepieces/pieces-framework": "0.14.0",
|
|
23
|
+
"@activepieces/shared": "0.13.1",
|
|
24
|
+
"tslib": "1.14.1"
|
|
25
|
+
},
|
|
26
|
+
"overrides": {
|
|
27
|
+
"@tryfabric/martian": {
|
|
28
|
+
"@notionhq/client": "$@notionhq/client"
|
|
29
|
+
},
|
|
30
|
+
"vite": {
|
|
31
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"resolutions": {
|
|
35
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
36
|
+
},
|
|
37
|
+
"main": "./src/index.js",
|
|
38
|
+
"type": "commonjs",
|
|
39
|
+
"types": "./src/index.d.ts"
|
|
40
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const microsoftOutlook: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftOutlook = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const download_email_attachment_1 = require("./lib/actions/download-email-attachment");
|
|
9
|
+
const send_email_1 = require("./lib/actions/send-email");
|
|
10
|
+
const auth_1 = require("./lib/common/auth");
|
|
11
|
+
const new_email_1 = require("./lib/triggers/new-email");
|
|
12
|
+
exports.microsoftOutlook = (0, pieces_framework_1.createPiece)({
|
|
13
|
+
displayName: 'Microsoft Outlook',
|
|
14
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
15
|
+
minimumSupportedRelease: '0.36.1',
|
|
16
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/outlook.png',
|
|
17
|
+
categories: [shared_1.PieceCategory.PRODUCTIVITY],
|
|
18
|
+
authors: ['lucaslimasouza', 'kishanprmr'],
|
|
19
|
+
actions: [
|
|
20
|
+
send_email_1.sendEmailAction,
|
|
21
|
+
download_email_attachment_1.downloadAttachmentAction,
|
|
22
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
23
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
24
|
+
baseUrl: () => 'https://graph.microsoft.com/v1.0/',
|
|
25
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
return ({
|
|
27
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
triggers: [new_email_1.newEmailTrigger],
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/microsoft-outlook/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAAkF;AAClF,iDAAqD;AACrD,uFAAmF;AACnF,yDAA2D;AAC3D,4CAAyD;AACzD,wDAA2D;AAE9C,QAAA,gBAAgB,GAAG,IAAA,8BAAW,EAAC;IAC3C,WAAW,EAAE,mBAAmB;IAChC,IAAI,EAAE,2BAAoB;IAC1B,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,UAAU,EAAE,CAAC,sBAAa,CAAC,YAAY,CAAC;IACxC,OAAO,EAAE,CAAC,gBAAgB,EAAE,YAAY,CAAC;IACzC,OAAO,EAAE;QACR,4BAAe;QACf,oDAAwB;QACxB,IAAA,yCAAyB,EAAC;YACzB,IAAI,EAAE,2BAAoB;YAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,mCAAmC;YAClD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC7B,aAAa,EAAE,UAAW,IAA4B,CAAC,YAAY,EAAE;iBACrE,CAAC,CAAA;cAAA;SACF,CAAC;KACF;IACD,QAAQ,EAAE,CAAC,2BAAe,CAAC;CAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const downloadAttachmentAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
messageId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadAttachmentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
exports.downloadAttachmentAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
10
|
+
name: 'downloadAttachment',
|
|
11
|
+
displayName: 'Download Attachment',
|
|
12
|
+
description: 'Download attachments from a specific email message.',
|
|
13
|
+
props: {
|
|
14
|
+
messageId: pieces_framework_1.Property.ShortText({
|
|
15
|
+
displayName: 'Message ID',
|
|
16
|
+
description: 'The ID of the email message containing the attachment.',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
run(context) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const { messageId } = context.propsValue;
|
|
23
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
24
|
+
authProvider: {
|
|
25
|
+
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const response = yield client
|
|
29
|
+
.api(`/me/messages/${messageId}/attachments`)
|
|
30
|
+
.get();
|
|
31
|
+
const attachments = [];
|
|
32
|
+
for (const attachment of response.value) {
|
|
33
|
+
if (attachment.name && attachment.contentBytes) {
|
|
34
|
+
attachments.push(Object.assign(Object.assign({}, attachment), { file: yield context.files.write({
|
|
35
|
+
fileName: attachment.name || 'test.png',
|
|
36
|
+
data: Buffer.from(attachment.contentBytes, 'base64'),
|
|
37
|
+
}) }));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return attachments;
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=download-email-attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-email-attachment.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-outlook/src/lib/actions/download-email-attachment.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,8EAA2E;AAE3E,yCAAsD;AAEzC,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACpD,IAAI,EAAE,2BAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE;QACN,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,wDAAwD;YACrE,QAAQ,EAAE,IAAI;SACd,CAAC;KACF;IACK,GAAG,CAAC,OAAO;;YAChB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEzC,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACxC,YAAY,EAAE;oBACb,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;iBAChE;aACD,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAmB,MAAM,MAAM;iBAC3C,GAAG,CAAC,gBAAgB,SAAS,cAAc,CAAC;iBAC5C,GAAG,EAAE,CAAC;YAER,MAAM,WAAW,GAAG,EAAE,CAAC;YAEvB,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,KAAyB,EAAE,CAAC;gBAC7D,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;oBAChD,WAAW,CAAC,IAAI,iCACZ,UAAU,KACb,IAAI,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;4BAC/B,QAAQ,EAAE,UAAU,CAAC,IAAI,IAAI,UAAU;4BACvC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC;yBACpD,CAAC,IACD,CAAC;gBACJ,CAAC;YACF,CAAC;YAGD,OAAO,WAAW,CAAC;QACpB,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const sendEmailAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
recipients: import("@activepieces/pieces-framework").ArrayProperty<true>;
|
|
3
|
+
ccRecipients: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
4
|
+
bccRecipients: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
5
|
+
subject: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
bodyFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
7
|
+
body: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
8
|
+
attachments: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendEmailAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
exports.sendEmailAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
10
|
+
name: 'send-email',
|
|
11
|
+
displayName: 'Send Email',
|
|
12
|
+
description: 'Sends an email using Microsoft Outlook.',
|
|
13
|
+
props: {
|
|
14
|
+
recipients: pieces_framework_1.Property.Array({
|
|
15
|
+
displayName: 'To Email(s)',
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
ccRecipients: pieces_framework_1.Property.Array({
|
|
19
|
+
displayName: 'CC Email(s)',
|
|
20
|
+
required: false,
|
|
21
|
+
defaultValue: [],
|
|
22
|
+
}),
|
|
23
|
+
bccRecipients: pieces_framework_1.Property.Array({
|
|
24
|
+
displayName: 'BCC Email(s)',
|
|
25
|
+
required: false,
|
|
26
|
+
defaultValue: [],
|
|
27
|
+
}),
|
|
28
|
+
subject: pieces_framework_1.Property.ShortText({
|
|
29
|
+
displayName: 'Subject',
|
|
30
|
+
required: true,
|
|
31
|
+
}),
|
|
32
|
+
bodyFormat: pieces_framework_1.Property.StaticDropdown({
|
|
33
|
+
displayName: 'Body Format',
|
|
34
|
+
required: true,
|
|
35
|
+
defaultValue: 'text',
|
|
36
|
+
options: {
|
|
37
|
+
disabled: false,
|
|
38
|
+
options: [
|
|
39
|
+
{ label: 'HTML', value: 'html' },
|
|
40
|
+
{ label: 'Text', value: 'text' },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
body: pieces_framework_1.Property.LongText({
|
|
45
|
+
displayName: 'Body',
|
|
46
|
+
required: true,
|
|
47
|
+
}),
|
|
48
|
+
attachments: pieces_framework_1.Property.Array({
|
|
49
|
+
displayName: 'Attachments',
|
|
50
|
+
required: false,
|
|
51
|
+
defaultValue: [],
|
|
52
|
+
properties: {
|
|
53
|
+
file: pieces_framework_1.Property.File({
|
|
54
|
+
displayName: 'File',
|
|
55
|
+
required: true,
|
|
56
|
+
}),
|
|
57
|
+
fileName: pieces_framework_1.Property.ShortText({
|
|
58
|
+
displayName: 'File Name',
|
|
59
|
+
required: false,
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
run(context) {
|
|
65
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const recipients = context.propsValue.recipients;
|
|
67
|
+
const ccRecipients = context.propsValue.ccRecipients;
|
|
68
|
+
const bccRecipients = context.propsValue.bccRecipients;
|
|
69
|
+
const attachments = context.propsValue.attachments;
|
|
70
|
+
const { subject, body, bodyFormat } = context.propsValue;
|
|
71
|
+
const mailPayload = {
|
|
72
|
+
subject,
|
|
73
|
+
body: {
|
|
74
|
+
content: body,
|
|
75
|
+
contentType: bodyFormat,
|
|
76
|
+
},
|
|
77
|
+
toRecipients: recipients.map((mail) => ({
|
|
78
|
+
emailAddress: {
|
|
79
|
+
address: mail,
|
|
80
|
+
},
|
|
81
|
+
})),
|
|
82
|
+
ccRecipients: ccRecipients.map((mail) => ({
|
|
83
|
+
emailAddress: {
|
|
84
|
+
address: mail,
|
|
85
|
+
},
|
|
86
|
+
})),
|
|
87
|
+
bccRecipients: bccRecipients.map((mail) => ({
|
|
88
|
+
emailAddress: {
|
|
89
|
+
address: mail,
|
|
90
|
+
},
|
|
91
|
+
})),
|
|
92
|
+
attachments: attachments.map((attachment) => ({
|
|
93
|
+
'@odata.type': '#microsoft.graph.fileAttachment',
|
|
94
|
+
name: attachment.fileName || attachment.file.filename,
|
|
95
|
+
contentBytes: attachment.file.base64,
|
|
96
|
+
})),
|
|
97
|
+
};
|
|
98
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
99
|
+
authProvider: {
|
|
100
|
+
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
const response = yield client.api('/me/sendMail').post({
|
|
104
|
+
message: mailPayload,
|
|
105
|
+
saveToSentItems: 'true',
|
|
106
|
+
});
|
|
107
|
+
return response;
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=send-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-email.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-outlook/src/lib/actions/send-email.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,8EAA2D;AAG3D,yCAAsD;AAEzC,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,2BAAoB;IAC1B,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACN,UAAU,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC5B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SAChB,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC7B,WAAW,EAAE,cAAc;YAC3B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SAChB,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,SAAS;YACtB,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,cAAc,CAAC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BACD,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACvC,YAAY,EAAE;wBACb,OAAO,EAAE,IAAI;qBACb;iBACD,CAAC,CAAC;gBACH,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACzC,YAAY,EAAE;wBACb,OAAO,EAAE,IAAI;qBACb;iBACD,CAAC,CAAC;gBACH,aAAa,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBAC3C,YAAY,EAAE;wBACb,OAAO,EAAE,IAAI;qBACb;iBACD,CAAC,CAAC;gBACH,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;oBAC7C,aAAa,EAAE,iCAAiC;oBAChD,IAAI,EAAE,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ;oBACrD,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM;iBACpC,CAAC,CAAC;aACH,CAAC;YAEF,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACxC,YAAY,EAAE;oBACb,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC;iBAChE;aACD,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC;gBACtD,OAAO,EAAE,WAAW;gBACpB,eAAe,EAAE,MAAM;aACvB,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QACjB,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const microsoftOutlookAuth: import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftOutlookAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
7
|
+
exports.microsoftOutlookAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
8
|
+
authUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
|
9
|
+
tokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
|
10
|
+
required: true,
|
|
11
|
+
scope: ['Mail.Read', 'Mail.Send', 'Calendars.Read', 'offline_access', 'User.Read'],
|
|
12
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
13
|
+
try {
|
|
14
|
+
const authValue = auth;
|
|
15
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
16
|
+
authProvider: {
|
|
17
|
+
getAccessToken: () => Promise.resolve(authValue.access_token),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
yield client.api('/me').get();
|
|
21
|
+
return { valid: true };
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return { valid: false, error: 'Invalid Credentials.' };
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-outlook/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,8EAA2D;AAE9C,QAAA,oBAAoB,GAAG,4BAAS,CAAC,MAAM,CAAC;IACpD,OAAO,EAAE,gEAAgE;IACzE,QAAQ,EAAE,4DAA4D;IACtE,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,CAAC;IAClF,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACxB,IAAI,CAAC;YACJ,MAAM,SAAS,GAAG,IAA2B,CAAC;YAC9C,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACxC,YAAY,EAAE;oBACb,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC;iBAC7D;aACD,CAAC,CAAC;YACH,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;YAC9B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;QACxD,CAAC;IACF,CAAC,CAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newEmailTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newEmailTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
8
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
9
|
+
const auth_1 = require("../common/auth");
|
|
10
|
+
const polling = {
|
|
11
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
12
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS }) {
|
|
13
|
+
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
14
|
+
authProvider: {
|
|
15
|
+
getAccessToken: () => Promise.resolve(auth.access_token),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const messages = [];
|
|
19
|
+
const filter = lastFetchEpochMS === 0
|
|
20
|
+
? '$top=10'
|
|
21
|
+
: `$filter=receivedDateTime gt ${(0, dayjs_1.default)(lastFetchEpochMS).toISOString()}`;
|
|
22
|
+
let response = yield client
|
|
23
|
+
.api(`/me/mailFolders/inbox/messages?${filter}`)
|
|
24
|
+
.orderby('receivedDateTime desc')
|
|
25
|
+
.get();
|
|
26
|
+
if (lastFetchEpochMS === 0) {
|
|
27
|
+
for (const message of response.value) {
|
|
28
|
+
messages.push(message);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
while (response.value.length > 0) {
|
|
33
|
+
for (const message of response.value) {
|
|
34
|
+
messages.push(message);
|
|
35
|
+
}
|
|
36
|
+
if (response['@odata.nextLink']) {
|
|
37
|
+
response = yield client.api(response['@odata.nextLink']).get();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return messages.map((message) => ({
|
|
45
|
+
epochMilliSeconds: (0, dayjs_1.default)(message.receivedDateTime).valueOf(),
|
|
46
|
+
data: message,
|
|
47
|
+
}));
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
exports.newEmailTrigger = (0, pieces_framework_1.createTrigger)({
|
|
51
|
+
auth: auth_1.microsoftOutlookAuth,
|
|
52
|
+
name: 'newEmail',
|
|
53
|
+
displayName: 'New Email',
|
|
54
|
+
description: 'Triggers when a new email is received in the inbox.',
|
|
55
|
+
props: {},
|
|
56
|
+
sampleData: {},
|
|
57
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
58
|
+
onEnable(context) {
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
61
|
+
auth: context.auth,
|
|
62
|
+
store: context.store,
|
|
63
|
+
propsValue: context.propsValue,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
onDisable(context) {
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
70
|
+
auth: context.auth,
|
|
71
|
+
store: context.store,
|
|
72
|
+
propsValue: context.propsValue,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
test(context) {
|
|
77
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
run(context) {
|
|
82
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=new-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-email.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/microsoft-outlook/src/lib/triggers/new-email.ts"],"names":[],"mappings":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