Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/gmail/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/gmail",
"version": "0.2.1",
"version": "0.2.2",
"description": "Pipedream Gmail Components",
"main": "gmail.app.mjs",
"keywords": [
Expand Down
17 changes: 14 additions & 3 deletions components/gmail/sources/new-email-received/new-email-received.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
name: "New Email Received",
description: "Emit new event when a new email is received.",
type: "source",
version: "0.1.10",
version: "0.1.11",
dedupe: "unique",
props: {
gmail,
Expand All @@ -31,14 +31,14 @@
"Configuring this source as a `webhook` (instant) trigger requires a custom OAuth client. [Refer to the guide here to get started](https://pipedream.com/apps/gmail/#getting-started).",
reloadProps: true,
},
serviceAccountKeyJson: {

Check warning on line 34 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop serviceAccountKeyJson must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "string",
label: "Service Account Key JSON",
optional: true,
hidden: true,
reloadProps: true,
},
serviceAccountKeyJsonInstructions: {

Check warning on line 41 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop serviceAccountKeyJsonInstructions must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 41 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop serviceAccountKeyJsonInstructions must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: `1) [Create a service account in GCP](https://cloud.google.com/iam/docs/creating-managing-service-accounts) and set the following permission: **Pub/Sub Admin**
Expand Down Expand Up @@ -96,7 +96,7 @@
optional: true,
hidden: true,
},
permissionAlert: {

Check warning on line 99 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop permissionAlert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 99 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop permissionAlert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "error",
content: `Unable to grant publish permission to Gmail API service account.
Expand All @@ -109,7 +109,7 @@
`,
hidden: true,
},
latencyWarningAlert: {

Check warning on line 112 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop latencyWarningAlert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 112 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop latencyWarningAlert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "warning",
content:
Expand Down Expand Up @@ -166,7 +166,7 @@
// create topic prop
let topicName = this.topic;
if (this.topicType === "new") {
const authKeyJSON = JSON.parse(this.serviceAccountKeyJson);
const authKeyJSON = this.getServiceAccountKeyJson();
const { project_id: projectId } = authKeyJSON;
topicName = `projects/${projectId}/topics/${this.convertNameToValidPubSubTopicName(
uuidv4(),
Expand Down Expand Up @@ -317,8 +317,18 @@
_setLastReceivedTime(lastReceivedTime) {
this.db.set("lastReceivedTime", lastReceivedTime);
},
getServiceAccountKeyJson() {
try {
return JSON.parse(this.serviceAccountKeyJson);
} catch (err) {
throw new ConfigurationError(`Error parsing \`Service Account Key JSON\`. Ensure its contents are valid JSON. \`${err}\``);
}
},
sdkParams() {
const authKeyJSON = JSON.parse(this.serviceAccountKeyJson);
if (!this.serviceAccountKeyJson) {
throw new ConfigurationError("Not able to create a webhook or subscribe to topics without configuring a service account. Please reconfigure the trigger type and try again.");
}
const authKeyJSON = this.getServiceAccountKeyJson();
const {
project_id: projectId, client_email, private_key,
} = authKeyJSON;
Expand All @@ -332,6 +342,7 @@
return sdkParams;
},
async getTopics() {

const sdkParams = this.sdkParams();
const pubSubClient = new PubSub(sdkParams);
const topics = (await pubSubClient.getTopics())[0];
Expand Down
3 changes: 1 addition & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading