Skip to content

Commit 69843dc

Browse files
authored
Merge branch 'master' into issue-13850
2 parents c59aab8 + bdc1166 commit 69843dc

File tree

41 files changed

+549
-958
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+549
-958
lines changed

components/gmail/actions/add-label-to-email/add-label-to-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-add-label-to-email",
55
name: "Add Label to Email",
66
description: "Add label(s) to an email message. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
gmail,

components/gmail/actions/create-draft/create-draft.mjs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import gmail from "../../gmail.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
import utils from "../../common/utils.mjs";
24

35
export default {
46
key: "gmail-create-draft",
57
name: "Create Draft",
68
description: "Create a draft from your Google Workspace email account. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.drafts/create)",
7-
version: "0.0.2",
9+
version: "0.0.3",
810
type: "action",
911
props: {
1012
gmail,
@@ -44,10 +46,16 @@ export default {
4446
"bodyType",
4547
],
4648
},
47-
attachments: {
49+
attachmentFilenames: {
4850
propDefinition: [
4951
gmail,
50-
"attachments",
52+
"attachmentFilenames",
53+
],
54+
},
55+
attachmentUrlsOrPaths: {
56+
propDefinition: [
57+
gmail,
58+
"attachmentUrlsOrPaths",
5159
],
5260
},
5361
inReplyTo: {
@@ -67,6 +75,11 @@ export default {
6775
},
6876
},
6977
async run({ $ }) {
78+
this.attachmentFilenames = utils.parseArray(this.attachmentFilenames);
79+
this.attachmentUrlsOrPaths = utils.parseArray(this.attachmentUrlsOrPaths);
80+
if (this.attachmentFilenames?.length !== this.attachmentUrlsOrPaths?.length) {
81+
throw new ConfigurationError("Must specify the same number of `Attachment Filenames` and `Attachment URLs or Paths`");
82+
}
7083
const opts = await this.gmail.getOptionsToSendEmail($, this);
7184
const response = await this.gmail.createDraft(opts);
7285
$.export("$summary", "Successfully created a draft message");

components/gmail/actions/download-attachment/download-attachment.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "gmail-download-attachment",
88
name: "Download Attachment",
99
description: "Download an attachment by attachmentId to the /tmp directory. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages.attachments/get)",
10-
version: "0.0.2",
10+
version: "0.0.3",
1111
type: "action",
1212
props: {
1313
gmail,

components/gmail/actions/find-email/find-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-find-email",
55
name: "Find Email",
66
description: "Find an email using Google's Search Engine. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
gmail,

components/gmail/actions/remove-label-from-email/remove-label-from-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-remove-label-from-email",
55
name: "Remove Label from Email",
66
description: "Remove label(s) from an email message. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
gmail,

components/gmail/actions/send-email/send-email.mjs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import gmail from "../../gmail.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
import utils from "../../common/utils.mjs";
24

35
export default {
46
key: "gmail-send-email",
57
name: "Send Email",
68
description: "Send an email from your Google Workspace email account. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send)",
7-
version: "0.1.4",
9+
version: "0.1.5",
810
type: "action",
911
props: {
1012
gmail,
@@ -32,6 +34,12 @@ export default {
3234
"fromName",
3335
],
3436
},
37+
fromEmail: {
38+
propDefinition: [
39+
gmail,
40+
"fromEmail",
41+
],
42+
},
3543
replyTo: {
3644
propDefinition: [
3745
gmail,
@@ -56,10 +64,16 @@ export default {
5664
"bodyType",
5765
],
5866
},
59-
attachments: {
67+
attachmentFilenames: {
68+
propDefinition: [
69+
gmail,
70+
"attachmentFilenames",
71+
],
72+
},
73+
attachmentUrlsOrPaths: {
6074
propDefinition: [
6175
gmail,
62-
"attachments",
76+
"attachmentUrlsOrPaths",
6377
],
6478
},
6579
inReplyTo: {
@@ -76,6 +90,11 @@ export default {
7690
},
7791
},
7892
async run({ $ }) {
93+
this.attachmentFilenames = utils.parseArray(this.attachmentFilenames);
94+
this.attachmentUrlsOrPaths = utils.parseArray(this.attachmentUrlsOrPaths);
95+
if (this.attachmentFilenames?.length !== this.attachmentUrlsOrPaths?.length) {
96+
throw new ConfigurationError("Must specify the same number of `Attachment Filenames` and `Attachment URLs or Paths`");
97+
}
7998
const opts = await this.gmail.getOptionsToSendEmail($, this);
8099
const response = await this.gmail.sendEmail(opts);
81100
$.export("$summary", `Successfully sent email to ${this.to}`);

components/gmail/actions/update-org-signature/update-org-signature.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "Update Signature for Email in Organization",
99
description: `Update the signature for a specific email address in an organization.
1010
A Google Cloud service account with delegated domain-wide authority is required for this action. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/update)`,
11-
version: "0.0.2",
11+
version: "0.0.3",
1212
type: "action",
1313
props: {
1414
gmail,

components/gmail/actions/update-primary-signature/update-primary-signature.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gmail-update-primary-signature",
55
name: "Update Signature for Primary Email Address",
66
description: "Update the signature for the primary email address. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/update)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
gmail,

components/gmail/common/utils.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function parseArray(arr) {
2+
if (!arr) {
3+
return undefined;
4+
}
5+
return typeof arr === "string"
6+
? JSON.parse(arr)
7+
: arr;
8+
}
9+
10+
export default {
11+
parseArray,
12+
};

components/gmail/gmail.app.mjs

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ export default {
195195
description: "Specify the name that will be displayed in the \"From\" section of the email.",
196196
optional: true,
197197
},
198+
fromEmail: {
199+
type: "string",
200+
label: "From Email",
201+
description: "Specify the email address that will be displayed in the \"From\" section of the email.",
202+
optional: true,
203+
async options() {
204+
const { sendAs } = await this.listSignatures();
205+
return sendAs
206+
.filter(({ sendAsEmail }) => sendAsEmail)
207+
.map(({ sendAsEmail }) => sendAsEmail);
208+
},
209+
},
198210
replyTo: {
199211
type: "string",
200212
label: "Reply To",
@@ -219,10 +231,16 @@ export default {
219231
default: "plaintext",
220232
options: Object.values(constants.BODY_TYPES),
221233
},
222-
attachments: {
223-
type: "object",
224-
label: "Attachments",
225-
description: "Add any attachments you'd like to include as objects.\n- The `key` should be the filename and must contain the file extension (e.g. `.jpeg`, `.txt`).\n- The `value` should be a URL of the download link for the file, or the local path (e.g. `/tmp/my-file.txt`).",
234+
attachmentFilenames: {
235+
type: "string[]",
236+
label: "Attachment Filenames",
237+
description: "Array of the names of the files to attach. Must contain the file extension (e.g. `.jpeg`, `.txt`). Use in conjuction with `Attachment URLs or Paths`.",
238+
optional: true,
239+
},
240+
attachmentUrlsOrPaths: {
241+
type: "string[]",
242+
label: "Attachment URLs or Paths",
243+
description: "Array of the URLs of the download links for the files, or the local paths (e.g. `/tmp/my-file.txt`). Use in conjuction with `Attachment Filenames`.",
226244
optional: true,
227245
},
228246
inReplyTo: {
@@ -260,11 +278,12 @@ export default {
260278
name: fromName,
261279
email,
262280
} = await this.userInfo();
281+
const fromEmail = props.fromEmail || email;
263282

264283
const opts = {
265284
from: props.fromName
266-
? `${props.fromName} <${email}>`
267-
: `${fromName} <${email}>`,
285+
? `${props.fromName} <${fromEmail}>`
286+
: `${fromName} <${fromEmail}>`,
268287
to: props.to,
269288
cc: props.cc,
270289
bcc: props.bcc,
@@ -289,18 +308,14 @@ export default {
289308
}
290309
}
291310

292-
if (props.attachments) {
293-
if (typeof props.attachments === "string") {
294-
props.attachments = JSON.parse(props.attachments);
311+
if (props.attachmentFilenames?.length && props.attachmentUrlsOrPaths?.length) {
312+
opts.attachments = [];
313+
for (let i = 0; i < props.attachmentFilenames.length; i++) {
314+
opts.attachments.push({
315+
filename: props.attachmentFilenames[i],
316+
path: props.attachmentUrlsOrPaths[i],
317+
});
295318
}
296-
opts.attachments = Object.entries(props.attachments)
297-
.map(([
298-
filename,
299-
path,
300-
]) => ({
301-
filename,
302-
path,
303-
}));
304319
}
305320

306321
if (props.bodyType === constants.BODY_TYPES.HTML) {

0 commit comments

Comments
 (0)