@activepieces/piece-microsoft-outlook 0.3.6 → 0.4.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/package.json +7 -13
- package/src/index.js +40 -63
- package/src/index.d.ts +0 -2
- package/src/index.d.ts.map +0 -1
- package/src/index.js.map +0 -1
- package/src/lib/actions/add-label-to-email.d.ts +0 -5
- package/src/lib/actions/add-label-to-email.d.ts.map +0 -1
- package/src/lib/actions/add-label-to-email.js +0 -50
- package/src/lib/actions/add-label-to-email.js.map +0 -1
- package/src/lib/actions/create-draft-email.d.ts +0 -10
- package/src/lib/actions/create-draft-email.d.ts.map +0 -1
- package/src/lib/actions/create-draft-email.js +0 -114
- package/src/lib/actions/create-draft-email.js.map +0 -1
- package/src/lib/actions/download-email-attachment.d.ts +0 -4
- package/src/lib/actions/download-email-attachment.d.ts.map +0 -1
- package/src/lib/actions/download-email-attachment.js +0 -50
- package/src/lib/actions/download-email-attachment.js.map +0 -1
- package/src/lib/actions/find-email.d.ts +0 -6
- package/src/lib/actions/find-email.d.ts.map +0 -1
- package/src/lib/actions/find-email.js +0 -73
- package/src/lib/actions/find-email.js.map +0 -1
- package/src/lib/actions/forward-email.d.ts +0 -6
- package/src/lib/actions/forward-email.d.ts.map +0 -1
- package/src/lib/actions/forward-email.js +0 -67
- package/src/lib/actions/forward-email.js.map +0 -1
- package/src/lib/actions/move-email-to-folder.d.ts +0 -5
- package/src/lib/actions/move-email-to-folder.d.ts.map +0 -1
- package/src/lib/actions/move-email-to-folder.js +0 -47
- package/src/lib/actions/move-email-to-folder.js.map +0 -1
- package/src/lib/actions/remove-label-from-email.d.ts +0 -5
- package/src/lib/actions/remove-label-from-email.d.ts.map +0 -1
- package/src/lib/actions/remove-label-from-email.js +0 -50
- package/src/lib/actions/remove-label-from-email.js.map +0 -1
- package/src/lib/actions/reply-email.d.ts +0 -10
- package/src/lib/actions/reply-email.d.ts.map +0 -1
- package/src/lib/actions/reply-email.js +0 -174
- package/src/lib/actions/reply-email.js.map +0 -1
- package/src/lib/actions/request-approval-send-email.d.ts +0 -6
- package/src/lib/actions/request-approval-send-email.d.ts.map +0 -1
- package/src/lib/actions/request-approval-send-email.js +0 -110
- package/src/lib/actions/request-approval-send-email.js.map +0 -1
- package/src/lib/actions/send-draft-email.d.ts +0 -4
- package/src/lib/actions/send-draft-email.d.ts.map +0 -1
- package/src/lib/actions/send-draft-email.js +0 -44
- package/src/lib/actions/send-draft-email.js.map +0 -1
- package/src/lib/actions/send-email.d.ts +0 -10
- package/src/lib/actions/send-email.d.ts.map +0 -1
- package/src/lib/actions/send-email.js +0 -117
- package/src/lib/actions/send-email.js.map +0 -1
- package/src/lib/common/auth.d.ts +0 -2
- package/src/lib/common/auth.d.ts.map +0 -1
- package/src/lib/common/auth.js +0 -51
- package/src/lib/common/auth.js.map +0 -1
- package/src/lib/common/microsoft-cloud.d.ts +0 -5
- package/src/lib/common/microsoft-cloud.d.ts.map +0 -1
- package/src/lib/common/microsoft-cloud.js +0 -38
- package/src/lib/common/microsoft-cloud.js.map +0 -1
- package/src/lib/common/props.d.ts +0 -10
- package/src/lib/common/props.d.ts.map +0 -1
- package/src/lib/common/props.js +0 -141
- package/src/lib/common/props.js.map +0 -1
- package/src/lib/triggers/new-attachment.d.ts +0 -19
- package/src/lib/triggers/new-attachment.d.ts.map +0 -1
- package/src/lib/triggers/new-attachment.js +0 -142
- package/src/lib/triggers/new-attachment.js.map +0 -1
- package/src/lib/triggers/new-email-in-folder.d.ts +0 -11
- package/src/lib/triggers/new-email-in-folder.d.ts.map +0 -1
- package/src/lib/triggers/new-email-in-folder.js +0 -102
- package/src/lib/triggers/new-email-in-folder.js.map +0 -1
- package/src/lib/triggers/new-email.d.ts +0 -15
- package/src/lib/triggers/new-email.d.ts.map +0 -1
- package/src/lib/triggers/new-email.js +0 -126
- package/src/lib/triggers/new-email.js.map +0 -1
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replyEmailAction = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const microsoft_cloud_1 = require("../common/microsoft-cloud");
|
|
7
|
-
const auth_1 = require("../common/auth");
|
|
8
|
-
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
9
|
-
exports.replyEmailAction = (0, pieces_framework_1.createAction)({
|
|
10
|
-
auth: auth_1.microsoftOutlookAuth,
|
|
11
|
-
name: 'reply-email',
|
|
12
|
-
displayName: 'Reply to Email',
|
|
13
|
-
description: 'Reply to an outlook email.',
|
|
14
|
-
audience: 'both',
|
|
15
|
-
aiMetadata: { description: 'Replies to an existing Outlook message (identified by message ID), supporting added CC/BCC recipients and attachments. Set the Create Draft flag to stage the reply without sending; otherwise it is sent immediately. Not idempotent when sending: each call creates and dispatches a new reply.', idempotent: false },
|
|
16
|
-
props: {
|
|
17
|
-
messageId: pieces_framework_1.Property.Dropdown({
|
|
18
|
-
auth: auth_1.microsoftOutlookAuth,
|
|
19
|
-
displayName: 'Email',
|
|
20
|
-
description: 'Select the email message to reply to.',
|
|
21
|
-
required: true,
|
|
22
|
-
refreshers: [],
|
|
23
|
-
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
24
|
-
var _b;
|
|
25
|
-
if (!auth) {
|
|
26
|
-
return {
|
|
27
|
-
disabled: true,
|
|
28
|
-
options: [],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const cloud = (_b = auth.props) === null || _b === void 0 ? void 0 : _b['cloud'];
|
|
32
|
-
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
33
|
-
authProvider: {
|
|
34
|
-
getAccessToken: () => Promise.resolve(auth.access_token),
|
|
35
|
-
},
|
|
36
|
-
baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
|
|
37
|
-
});
|
|
38
|
-
try {
|
|
39
|
-
const response = yield client
|
|
40
|
-
.api('/me/messages?$top=50&$select=id,subject,from,receivedDateTime')
|
|
41
|
-
.orderby('receivedDateTime desc')
|
|
42
|
-
.get();
|
|
43
|
-
const messages = response.value;
|
|
44
|
-
return {
|
|
45
|
-
disabled: false,
|
|
46
|
-
options: messages.map((message) => {
|
|
47
|
-
var _a, _b, _c, _d;
|
|
48
|
-
return ({
|
|
49
|
-
label: `${message.subject || 'No Subject'} - ${((_b = (_a = message.from) === null || _a === void 0 ? void 0 : _a.emailAddress) === null || _b === void 0 ? void 0 : _b.name) || ((_d = (_c = message.from) === null || _c === void 0 ? void 0 : _c.emailAddress) === null || _d === void 0 ? void 0 : _d.address) || 'Unknown Sender'}`,
|
|
50
|
-
value: message.id || '',
|
|
51
|
-
});
|
|
52
|
-
}),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
return {
|
|
57
|
-
disabled: true,
|
|
58
|
-
options: [],
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
}),
|
|
63
|
-
bodyFormat: pieces_framework_1.Property.StaticDropdown({
|
|
64
|
-
displayName: 'Body Format',
|
|
65
|
-
required: true,
|
|
66
|
-
defaultValue: 'text',
|
|
67
|
-
options: {
|
|
68
|
-
disabled: false,
|
|
69
|
-
options: [
|
|
70
|
-
{ label: 'HTML', value: 'html' },
|
|
71
|
-
{ label: 'Text', value: 'text' },
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
}),
|
|
75
|
-
replyBody: pieces_framework_1.Property.LongText({
|
|
76
|
-
displayName: 'Reply Body',
|
|
77
|
-
required: true,
|
|
78
|
-
}),
|
|
79
|
-
ccRecipients: pieces_framework_1.Property.Array({
|
|
80
|
-
displayName: 'CC Recipients',
|
|
81
|
-
required: false,
|
|
82
|
-
}),
|
|
83
|
-
bccRecipients: pieces_framework_1.Property.Array({
|
|
84
|
-
displayName: 'BCC Recipients',
|
|
85
|
-
required: false,
|
|
86
|
-
}),
|
|
87
|
-
attachments: pieces_framework_1.Property.Array({
|
|
88
|
-
displayName: 'Attachments',
|
|
89
|
-
required: false,
|
|
90
|
-
defaultValue: [],
|
|
91
|
-
properties: {
|
|
92
|
-
file: pieces_framework_1.Property.File({
|
|
93
|
-
displayName: 'File',
|
|
94
|
-
required: true,
|
|
95
|
-
}),
|
|
96
|
-
fileName: pieces_framework_1.Property.ShortText({
|
|
97
|
-
displayName: 'File Name',
|
|
98
|
-
required: false,
|
|
99
|
-
}),
|
|
100
|
-
},
|
|
101
|
-
}),
|
|
102
|
-
draft: pieces_framework_1.Property.Checkbox({
|
|
103
|
-
displayName: 'Create Draft',
|
|
104
|
-
description: 'If enabled, creates draft without sending.',
|
|
105
|
-
required: true,
|
|
106
|
-
defaultValue: false,
|
|
107
|
-
}),
|
|
108
|
-
},
|
|
109
|
-
run(context) {
|
|
110
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
var _a;
|
|
112
|
-
const { replyBody, bodyFormat, messageId, draft } = context.propsValue;
|
|
113
|
-
const ccRecipients = context.propsValue.ccRecipients;
|
|
114
|
-
const bccRecipients = context.propsValue.bccRecipients;
|
|
115
|
-
const attachments = context.propsValue.attachments;
|
|
116
|
-
const mailPayload = {
|
|
117
|
-
body: {
|
|
118
|
-
content: replyBody,
|
|
119
|
-
contentType: bodyFormat,
|
|
120
|
-
},
|
|
121
|
-
ccRecipients: ccRecipients.map((mail) => ({
|
|
122
|
-
emailAddress: {
|
|
123
|
-
address: mail,
|
|
124
|
-
},
|
|
125
|
-
})),
|
|
126
|
-
bccRecipients: bccRecipients.map((mail) => ({
|
|
127
|
-
emailAddress: {
|
|
128
|
-
address: mail,
|
|
129
|
-
},
|
|
130
|
-
})),
|
|
131
|
-
attachments: attachments.map((attachment) => ({
|
|
132
|
-
'@odata.type': '#microsoft.graph.fileAttachment',
|
|
133
|
-
name: attachment.fileName || attachment.file.filename,
|
|
134
|
-
contentBytes: attachment.file.base64,
|
|
135
|
-
})),
|
|
136
|
-
};
|
|
137
|
-
const cloud = (_a = context.auth.props) === null || _a === void 0 ? void 0 : _a['cloud'];
|
|
138
|
-
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
139
|
-
authProvider: {
|
|
140
|
-
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
141
|
-
},
|
|
142
|
-
baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
|
|
143
|
-
});
|
|
144
|
-
try {
|
|
145
|
-
const response = yield client
|
|
146
|
-
.api(`/me/messages/${messageId}/createReply`)
|
|
147
|
-
.post({
|
|
148
|
-
message: mailPayload,
|
|
149
|
-
});
|
|
150
|
-
const draftId = response.id;
|
|
151
|
-
if (!draft) {
|
|
152
|
-
yield client.api(`/me/messages/${draftId}/send`).post({});
|
|
153
|
-
return {
|
|
154
|
-
success: true,
|
|
155
|
-
message: 'Reply sent successfully.',
|
|
156
|
-
draftId: draftId,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
success: true,
|
|
161
|
-
message: 'Draft created successfully.',
|
|
162
|
-
draftId: draftId,
|
|
163
|
-
draftLink: `https://outlook.office.com/mail/drafts/id/${draftId}`,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
console.error('Reply Email Error:', error);
|
|
168
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
169
|
-
throw new Error(errorMessage);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
//# sourceMappingURL=reply-email.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reply-email.js","sourceRoot":"","sources":["../../../../src/lib/actions/reply-email.ts"],"names":[],"mappings":";;;;AAAA,qEAAqG;AACrG,+DAA4D;AAC5D,yCAAsD;AAEtD,8EAA2E;AAE9D,QAAA,gBAAg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,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBAC3D,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const requestApprovalInMail: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
-
recipients: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
-
body: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
5
|
-
}>;
|
|
6
|
-
//# sourceMappingURL=request-approval-send-email.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-approval-send-email.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/request-approval-send-email.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,qBAAqB;;;;EA6GhC,CAAC"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requestApprovalInMail = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const microsoft_cloud_1 = require("../common/microsoft-cloud");
|
|
7
|
-
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
8
|
-
const shared_1 = require("@activepieces/shared");
|
|
9
|
-
const auth_1 = require("../common/auth");
|
|
10
|
-
exports.requestApprovalInMail = (0, pieces_framework_1.createAction)({
|
|
11
|
-
auth: auth_1.microsoftOutlookAuth,
|
|
12
|
-
name: 'request_approval_in_mail',
|
|
13
|
-
displayName: 'Request Approval in Email',
|
|
14
|
-
description: 'Send approval request email and then wait until the email is approved or disapproved',
|
|
15
|
-
audience: 'both',
|
|
16
|
-
aiMetadata: { description: 'Sends an email containing Approve/Disapprove links to one recipient, then pauses the flow until they click one of the links, resuming with the decision. Use this as a human-in-the-loop approval gate before proceeding. Not idempotent: each call sends a new email and creates a new pending waitpoint.', idempotent: false },
|
|
17
|
-
props: {
|
|
18
|
-
recipients: pieces_framework_1.Property.ShortText({
|
|
19
|
-
displayName: 'To Email Address',
|
|
20
|
-
description: 'The email address of the recipient who will receive the approval request.',
|
|
21
|
-
required: true,
|
|
22
|
-
}),
|
|
23
|
-
subject: pieces_framework_1.Property.ShortText({
|
|
24
|
-
displayName: 'Subject',
|
|
25
|
-
description: 'The subject of the approval request email.',
|
|
26
|
-
required: true,
|
|
27
|
-
}),
|
|
28
|
-
body: pieces_framework_1.Property.LongText({
|
|
29
|
-
displayName: 'Body',
|
|
30
|
-
description: 'The main content of the email. You can include details about the approval request here in the html format or plain text.',
|
|
31
|
-
required: true,
|
|
32
|
-
}),
|
|
33
|
-
},
|
|
34
|
-
run(context) {
|
|
35
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
var _a;
|
|
37
|
-
if (context.executionType === shared_1.ExecutionType.BEGIN) {
|
|
38
|
-
try {
|
|
39
|
-
const token = context.auth.access_token;
|
|
40
|
-
const recipients = context.propsValue.recipients;
|
|
41
|
-
const { subject, body } = context.propsValue;
|
|
42
|
-
(0, shared_1.assertNotNullOrUndefined)(token, 'token');
|
|
43
|
-
(0, shared_1.assertNotNullOrUndefined)(recipients, 'recipients');
|
|
44
|
-
(0, shared_1.assertNotNullOrUndefined)(subject, 'subject');
|
|
45
|
-
(0, shared_1.assertNotNullOrUndefined)(body, 'body');
|
|
46
|
-
const waitpoint = yield context.run.createWaitpoint({
|
|
47
|
-
type: 'WEBHOOK',
|
|
48
|
-
});
|
|
49
|
-
const approvalLink = waitpoint.buildResumeUrl({
|
|
50
|
-
queryParams: { action: 'approve' },
|
|
51
|
-
});
|
|
52
|
-
const disapprovalLink = waitpoint.buildResumeUrl({
|
|
53
|
-
queryParams: { action: 'disapprove' },
|
|
54
|
-
});
|
|
55
|
-
const htmlBody = `
|
|
56
|
-
<div>
|
|
57
|
-
<p>${body}</p>
|
|
58
|
-
<br />
|
|
59
|
-
<p>
|
|
60
|
-
<a href="${approvalLink}" style="display: inline-block; padding: 10px 20px; margin-right: 10px; background-color: #28a745; color: white; text-decoration: none; border-radius: 4px;">Approve</a>
|
|
61
|
-
<a href="${disapprovalLink}" style="display: inline-block; padding: 10px 20px; background-color: #dc3545; color: white; text-decoration: none; border-radius: 4px;">Disapprove</a>
|
|
62
|
-
</p>
|
|
63
|
-
</div>
|
|
64
|
-
`;
|
|
65
|
-
const cloud = (_a = context.auth.props) === null || _a === void 0 ? void 0 : _a['cloud'];
|
|
66
|
-
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
67
|
-
authProvider: {
|
|
68
|
-
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
69
|
-
},
|
|
70
|
-
baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
|
|
71
|
-
});
|
|
72
|
-
const mailPayload = {
|
|
73
|
-
subject,
|
|
74
|
-
body: {
|
|
75
|
-
content: htmlBody,
|
|
76
|
-
contentType: 'html',
|
|
77
|
-
},
|
|
78
|
-
toRecipients: [
|
|
79
|
-
{
|
|
80
|
-
emailAddress: {
|
|
81
|
-
address: recipients,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
};
|
|
86
|
-
const sendResult = yield client.api('/me/sendMail').post({
|
|
87
|
-
message: mailPayload,
|
|
88
|
-
saveToSentItems: true,
|
|
89
|
-
});
|
|
90
|
-
context.run.waitForWaitpoint(waitpoint.id);
|
|
91
|
-
return {
|
|
92
|
-
approved: false, // default approval is false
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
console.error('[RequestApprovalEmail] Error during BEGIN execution:', error);
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
const action = context.resumePayload.queryParams['action'];
|
|
102
|
-
const approved = action === 'approve';
|
|
103
|
-
return {
|
|
104
|
-
approved,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
//# sourceMappingURL=request-approval-send-email.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-approval-send-email.js","sourceRoot":"","sources":["../../../../src/lib/actions/request-approval-send-email.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAA4D;AAC5D,8EAA2D;AAE3D,iDAG8B;AAC9B,yCAAsD;AAEzC,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,2BAAoB;IAC1B,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,2BAA2B;IACxC,WAAW,EACT,sFAAsF;IACxF,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,4SAA4S,EAAE,UAAU,EAAE,KAAK,EAAE;IAC5V,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EACT,2EAA2E;YAC7E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,MAAM;YACnB,WAAW,EACT,0HAA0H;YAC5H,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,IAAI,OAAO,CAAC,aAAa,KAAK,sBAAa,CAAC,KAAK,EAAE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AAM,WAAW,GAAG;wBAClB,OAAO;wBACP,IAAI,EAAE;4BACJ,OAAO,EAAE,QAAQ;4BACjB,WAAW,EAAE,MAAkB;yBAChC;wBACD,YAAY,EAAE;4BACZ;gCACE,YAAY,EAAE;oCACZ,OAAO,EAAE,UAAU;iCACpB;6BACF;yBACF;qBACF,CAAC;oBAEF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC;wBACvD,OAAO,EAAE,WAAW;wBACpB,eAAe,EAAE,IAAI;qBACtB,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;oBAE3C,OAAO;wBACL,QAAQ,EAAE,KAAK,EAAE,4BAA4B;qBAC9C,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CACX,sDAAsD,EACtD,KAAK,CACN,CAAC;oBACF,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;gBAC3D,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,CAAC;gBAEtC,OAAO;oBACL,QAAQ;iBACT,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const sendDraftEmailAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
-
messageId: import("@activepieces/pieces-framework").DropdownProperty<string | undefined, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>> | import("@activepieces/pieces-framework").DropdownProperty<string | undefined, true, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
3
|
-
}>;
|
|
4
|
-
//# sourceMappingURL=send-draft-email.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"send-draft-email.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/send-draft-email.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB;;EAiC/B,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendDraftEmailAction = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const microsoft_cloud_1 = require("../common/microsoft-cloud");
|
|
7
|
-
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
8
|
-
const auth_1 = require("../common/auth");
|
|
9
|
-
const props_1 = require("../common/props");
|
|
10
|
-
exports.sendDraftEmailAction = (0, pieces_framework_1.createAction)({
|
|
11
|
-
auth: auth_1.microsoftOutlookAuth,
|
|
12
|
-
name: 'sendDraftEmail',
|
|
13
|
-
displayName: 'Send Draft Email',
|
|
14
|
-
description: 'Sends a draft email message.',
|
|
15
|
-
audience: 'both',
|
|
16
|
-
aiMetadata: { description: 'Sends an existing draft email (identified by draft message ID) from the Outlook mailbox. Use this to dispatch a draft previously staged by Create Draft Email or a draft reply. Not idempotent: once sent the draft no longer exists, so re-running with the same ID will fail.', idempotent: false },
|
|
17
|
-
props: {
|
|
18
|
-
messageId: (0, props_1.draftMessageIdDropdown)({
|
|
19
|
-
displayName: 'Draft Email',
|
|
20
|
-
description: 'Select the draft email message to send.',
|
|
21
|
-
required: true,
|
|
22
|
-
}),
|
|
23
|
-
},
|
|
24
|
-
run(context) {
|
|
25
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
var _a;
|
|
27
|
-
const { messageId } = context.propsValue;
|
|
28
|
-
const cloud = (_a = context.auth.props) === null || _a === void 0 ? void 0 : _a['cloud'];
|
|
29
|
-
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
30
|
-
authProvider: {
|
|
31
|
-
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
32
|
-
},
|
|
33
|
-
baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
|
|
34
|
-
});
|
|
35
|
-
yield client.api(`/me/messages/${messageId}/send`).post({});
|
|
36
|
-
return {
|
|
37
|
-
success: true,
|
|
38
|
-
message: 'Draft sent successfully.',
|
|
39
|
-
messageId: messageId,
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=send-draft-email.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"send-draft-email.js","sourceRoot":"","sources":["../../../../src/lib/actions/send-draft-email.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAA4D;AAC5D,8EAA2D;AAC3D,yCAAsD;AACtD,2CAAyD;AAE5C,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,2BAAoB;IAC1B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,8BAA8B;IAC3C,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,iRAAiR,EAAE,UAAU,EAAE,KAAK,EAAE;IACjU,KAAK,EAAE;QACN,SAAS,EAAE,IAAA,8BAAsB,EAAC;YACjC,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,IAAI;SACd,CAAC;KACF;IACK,GAAG,CAAC,OAAO;;;YAChB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAEzC,MAAM,KAAK,GAAG,MAAA,OAAO,CAAC,IAAI,CAAC,KAAK,0CAAG,OAAO,CAAuB,CAAC;YAClE,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;gBACD,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC;aAC/B,CAAC,CAAC;YAEH,MAAM,MAAM,CAAC,GAAG,CAAC,gBAAgB,SAAS,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAE5D,OAAO;gBACN,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,0BAA0B;gBACnC,SAAS,EAAE,SAAS;aACpB,CAAC;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}>;
|
|
10
|
-
//# sourceMappingURL=send-email.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"send-email.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/send-email.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe;;;;;;;;EA6G1B,CAAC"}
|
|
@@ -1,117 +0,0 @@
|
|
|
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_cloud_1 = require("../common/microsoft-cloud");
|
|
7
|
-
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
8
|
-
const auth_1 = require("../common/auth");
|
|
9
|
-
exports.sendEmailAction = (0, pieces_framework_1.createAction)({
|
|
10
|
-
auth: auth_1.microsoftOutlookAuth,
|
|
11
|
-
name: 'send-email',
|
|
12
|
-
displayName: 'Send Email',
|
|
13
|
-
description: 'Sends an email using Microsoft Outlook.',
|
|
14
|
-
audience: 'both',
|
|
15
|
-
aiMetadata: { description: 'Composes and sends a new email from the authenticated Outlook mailbox to the given recipients, with optional CC/BCC and file attachments. Use this to send a fresh message (not a reply or forward). Not idempotent: each call dispatches a new email and saves a copy to Sent Items.', idempotent: false },
|
|
16
|
-
props: {
|
|
17
|
-
recipients: pieces_framework_1.Property.Array({
|
|
18
|
-
displayName: 'To Email(s)',
|
|
19
|
-
required: true,
|
|
20
|
-
}),
|
|
21
|
-
ccRecipients: pieces_framework_1.Property.Array({
|
|
22
|
-
displayName: 'CC Email(s)',
|
|
23
|
-
required: false,
|
|
24
|
-
defaultValue: [],
|
|
25
|
-
}),
|
|
26
|
-
bccRecipients: pieces_framework_1.Property.Array({
|
|
27
|
-
displayName: 'BCC Email(s)',
|
|
28
|
-
required: false,
|
|
29
|
-
defaultValue: [],
|
|
30
|
-
}),
|
|
31
|
-
subject: pieces_framework_1.Property.ShortText({
|
|
32
|
-
displayName: 'Subject',
|
|
33
|
-
required: true,
|
|
34
|
-
}),
|
|
35
|
-
bodyFormat: pieces_framework_1.Property.StaticDropdown({
|
|
36
|
-
displayName: 'Body Format',
|
|
37
|
-
required: true,
|
|
38
|
-
defaultValue: 'text',
|
|
39
|
-
options: {
|
|
40
|
-
disabled: false,
|
|
41
|
-
options: [
|
|
42
|
-
{ label: 'HTML', value: 'html' },
|
|
43
|
-
{ label: 'Text', value: 'text' },
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
}),
|
|
47
|
-
body: pieces_framework_1.Property.LongText({
|
|
48
|
-
displayName: 'Body',
|
|
49
|
-
required: true,
|
|
50
|
-
}),
|
|
51
|
-
attachments: pieces_framework_1.Property.Array({
|
|
52
|
-
displayName: 'Attachments',
|
|
53
|
-
required: false,
|
|
54
|
-
defaultValue: [],
|
|
55
|
-
properties: {
|
|
56
|
-
file: pieces_framework_1.Property.File({
|
|
57
|
-
displayName: 'File',
|
|
58
|
-
required: true,
|
|
59
|
-
}),
|
|
60
|
-
fileName: pieces_framework_1.Property.ShortText({
|
|
61
|
-
displayName: 'File Name',
|
|
62
|
-
required: false,
|
|
63
|
-
}),
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
},
|
|
67
|
-
run(context) {
|
|
68
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
var _a;
|
|
70
|
-
const recipients = context.propsValue.recipients;
|
|
71
|
-
const ccRecipients = context.propsValue.ccRecipients;
|
|
72
|
-
const bccRecipients = context.propsValue.bccRecipients;
|
|
73
|
-
const attachments = context.propsValue.attachments;
|
|
74
|
-
const { subject, body, bodyFormat } = context.propsValue;
|
|
75
|
-
const mailPayload = {
|
|
76
|
-
subject,
|
|
77
|
-
body: {
|
|
78
|
-
content: body,
|
|
79
|
-
contentType: bodyFormat,
|
|
80
|
-
},
|
|
81
|
-
toRecipients: recipients.map((mail) => ({
|
|
82
|
-
emailAddress: {
|
|
83
|
-
address: mail,
|
|
84
|
-
},
|
|
85
|
-
})),
|
|
86
|
-
ccRecipients: ccRecipients.map((mail) => ({
|
|
87
|
-
emailAddress: {
|
|
88
|
-
address: mail,
|
|
89
|
-
},
|
|
90
|
-
})),
|
|
91
|
-
bccRecipients: bccRecipients.map((mail) => ({
|
|
92
|
-
emailAddress: {
|
|
93
|
-
address: mail,
|
|
94
|
-
},
|
|
95
|
-
})),
|
|
96
|
-
attachments: attachments.map((attachment) => ({
|
|
97
|
-
'@odata.type': '#microsoft.graph.fileAttachment',
|
|
98
|
-
name: attachment.fileName || attachment.file.filename,
|
|
99
|
-
contentBytes: attachment.file.base64,
|
|
100
|
-
})),
|
|
101
|
-
};
|
|
102
|
-
const cloud = (_a = context.auth.props) === null || _a === void 0 ? void 0 : _a['cloud'];
|
|
103
|
-
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
104
|
-
authProvider: {
|
|
105
|
-
getAccessToken: () => Promise.resolve(context.auth.access_token),
|
|
106
|
-
},
|
|
107
|
-
baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
|
|
108
|
-
});
|
|
109
|
-
const response = yield client.api('/me/sendMail').post({
|
|
110
|
-
message: mailPayload,
|
|
111
|
-
saveToSentItems: 'true',
|
|
112
|
-
});
|
|
113
|
-
return response;
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
//# sourceMappingURL=send-email.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"send-email.js","sourceRoot":"","sources":["../../../../src/lib/actions/send-email.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,+DAA4D;AAC5D,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,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,uRAAuR,EAAE,UAAU,EAAE,KAAK,EAAE;IACvU,KAAK,EAAE;QACN,UAAU,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,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AM,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;gBACD,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC;aAC/B,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"}
|
package/src/lib/common/auth.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,oBAAoB,+GAgC/B,CAAC"}
|
package/src/lib/common/auth.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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_cloud_1 = require("./microsoft-cloud");
|
|
7
|
-
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
8
|
-
const authDesc = `
|
|
9
|
-
If you’d like to use your own custom Azure app instead of the default app, follow the [Azure app creation guide](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application),
|
|
10
|
-
set the **Redirect URI** to {{redirectUrl}} and add the following **Microsoft Graph (Delegated) permissions** under **API permissions**:
|
|
11
|
-
- User.Read
|
|
12
|
-
- Mail.ReadWrite
|
|
13
|
-
- Mail.Send
|
|
14
|
-
- Calendars.Read
|
|
15
|
-
- offline_access
|
|
16
|
-
`;
|
|
17
|
-
exports.microsoftOutlookAuth = pieces_framework_1.PieceAuth.OAuth2({
|
|
18
|
-
description: authDesc,
|
|
19
|
-
props: {
|
|
20
|
-
cloud: microsoft_cloud_1.microsoftCloudProperty,
|
|
21
|
-
},
|
|
22
|
-
authUrl: 'https://{cloud}/common/oauth2/v2.0/authorize',
|
|
23
|
-
tokenUrl: 'https://{cloud}/common/oauth2/v2.0/token',
|
|
24
|
-
required: true,
|
|
25
|
-
scope: [
|
|
26
|
-
'Mail.ReadWrite',
|
|
27
|
-
'Mail.Send',
|
|
28
|
-
'Calendars.Read',
|
|
29
|
-
'offline_access',
|
|
30
|
-
'User.Read',
|
|
31
|
-
],
|
|
32
|
-
prompt: 'omit',
|
|
33
|
-
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
34
|
-
try {
|
|
35
|
-
const authValue = auth;
|
|
36
|
-
const cloud = (0, microsoft_cloud_1.getMicrosoftCloudFromAuth)(authValue);
|
|
37
|
-
const client = microsoft_graph_client_1.Client.initWithMiddleware({
|
|
38
|
-
authProvider: {
|
|
39
|
-
getAccessToken: () => Promise.resolve(authValue.access_token),
|
|
40
|
-
},
|
|
41
|
-
baseUrl: (0, microsoft_cloud_1.getGraphBaseUrl)(cloud),
|
|
42
|
-
});
|
|
43
|
-
yield client.api('/me').get();
|
|
44
|
-
return { valid: true };
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
return { valid: false, error: 'Invalid Credentials.' };
|
|
48
|
-
}
|
|
49
|
-
}),
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,uDAAuG;AACvG,8EAA2D;AAE3D,MAAM,QAAQ,GAAG;;;;;;;;CAQhB,CAAC;AAEW,QAAA,oBAAoB,GAAG,4BAAS,CAAC,MAAM,CAAC;IACnD,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE;QACL,KAAK,EAAE,wCAAsB;KAC9B;IACD,OAAO,EAAE,8CAA8C;IACvD,QAAQ,EAAE,0CAA0C;IACpD,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,gBAAgB;QAChB,WAAW;QACX,gBAAgB;QAChB,gBAAgB;QAChB,WAAW;KACZ;IACD,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAA2B,CAAC;YAC9C,MAAM,KAAK,GAAG,IAAA,2CAAyB,EAAC,SAAS,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,+BAAM,CAAC,kBAAkB,CAAC;gBACvC,YAAY,EAAE;oBACZ,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC;iBAC9D;gBACD,OAAO,EAAE,IAAA,iCAAe,EAAC,KAAK,CAAC;aAChC,CAAC,CAAC;YACH,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;YAC9B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;QACzD,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { OAuth2PropertyValue } from '@activepieces/pieces-framework';
|
|
2
|
-
export declare const microsoftCloudProperty: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
-
export declare function getMicrosoftCloudFromAuth(auth: OAuth2PropertyValue): string;
|
|
4
|
-
export declare function getGraphBaseUrl(cloudLoginHost: string | undefined | null): string;
|
|
5
|
-
//# sourceMappingURL=microsoft-cloud.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"microsoft-cloud.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/microsoft-cloud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,gCAAgC,CAAC;AAU/E,eAAO,MAAM,sBAAsB,+EAYjC,CAAC;AAMH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAE3E;AAED,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAGjF"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.microsoftCloudProperty = void 0;
|
|
4
|
-
exports.getMicrosoftCloudFromAuth = getMicrosoftCloudFromAuth;
|
|
5
|
-
exports.getGraphBaseUrl = getGraphBaseUrl;
|
|
6
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
-
const COMMERCIAL_LOGIN_HOST = 'login.microsoftonline.com';
|
|
8
|
-
const GOV_LOGIN_HOST = 'login.microsoftonline.us';
|
|
9
|
-
const GRAPH_BASE_URLS = {
|
|
10
|
-
[COMMERCIAL_LOGIN_HOST]: 'https://graph.microsoft.com',
|
|
11
|
-
[GOV_LOGIN_HOST]: 'https://graph.microsoft.us',
|
|
12
|
-
};
|
|
13
|
-
exports.microsoftCloudProperty = pieces_framework_1.Property.StaticDropdown({
|
|
14
|
-
displayName: 'Cloud Environment',
|
|
15
|
-
description: 'Select your Microsoft cloud environment.',
|
|
16
|
-
required: true,
|
|
17
|
-
defaultValue: COMMERCIAL_LOGIN_HOST,
|
|
18
|
-
options: {
|
|
19
|
-
disabled: false,
|
|
20
|
-
options: [
|
|
21
|
-
{ label: 'Commercial (Global)', value: COMMERCIAL_LOGIN_HOST },
|
|
22
|
-
{ label: 'US Government (GCC High)', value: GOV_LOGIN_HOST },
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
function resolveCloudHost(cloudLoginHost) {
|
|
27
|
-
return cloudLoginHost !== null && cloudLoginHost !== void 0 ? cloudLoginHost : COMMERCIAL_LOGIN_HOST;
|
|
28
|
-
}
|
|
29
|
-
function getMicrosoftCloudFromAuth(auth) {
|
|
30
|
-
var _a;
|
|
31
|
-
return resolveCloudHost((_a = auth.props) === null || _a === void 0 ? void 0 : _a['cloud']);
|
|
32
|
-
}
|
|
33
|
-
function getGraphBaseUrl(cloudLoginHost) {
|
|
34
|
-
var _a;
|
|
35
|
-
const host = resolveCloudHost(cloudLoginHost);
|
|
36
|
-
return (_a = GRAPH_BASE_URLS[host]) !== null && _a !== void 0 ? _a : GRAPH_BASE_URLS[COMMERCIAL_LOGIN_HOST];
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=microsoft-cloud.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"microsoft-cloud.js","sourceRoot":"","sources":["../../../../src/lib/common/microsoft-cloud.ts"],"names":[],"mappings":";;;AA4BA,8DAEC;AAED,0CAGC;AAnCD,qEAA+E;AAE/E,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAC1D,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAElD,MAAM,eAAe,GAA2B;IAC9C,CAAC,qBAAqB,CAAC,EAAE,6BAA6B;IACtD,CAAC,cAAc,CAAC,EAAE,4BAA4B;CAC/C,CAAC;AAEW,QAAA,sBAAsB,GAAG,2BAAQ,CAAC,cAAc,CAAC;IAC5D,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,0CAA0C;IACvD,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,qBAAqB;IACnC,OAAO,EAAE;QACP,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,qBAAqB,EAAE;YAC9D,EAAE,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,cAAc,EAAE;SAC7D;KACF;CACF,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,cAAyC;IACjE,OAAO,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,qBAAqB,CAAC;AACjD,CAAC;AAED,SAAgB,yBAAyB,CAAC,IAAyB;;IACjE,OAAO,gBAAgB,CAAC,MAAA,IAAI,CAAC,KAAK,0CAAG,OAAO,CAAuB,CAAC,CAAC;AACvE,CAAC;AAED,SAAgB,eAAe,CAAC,cAAyC;;IACvE,MAAM,IAAI,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAC9C,OAAO,MAAA,eAAe,CAAC,IAAI,CAAC,mCAAI,eAAe,CAAC,qBAAqB,CAAC,CAAC;AACzE,CAAC"}
|