diff --git a/components/gmail_custom_oauth/.gitignore b/components/gmail_custom_oauth/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/gmail_custom_oauth/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/gmail_custom_oauth/actions/add-label-to-email/add-label-to-email.mjs b/components/gmail_custom_oauth/actions/add-label-to-email/add-label-to-email.mjs new file mode 100644 index 0000000000000..a2aa1e8931445 --- /dev/null +++ b/components/gmail_custom_oauth/actions/add-label-to-email/add-label-to-email.mjs @@ -0,0 +1,13 @@ +/* eslint-disable pipedream/required-properties-name */ +/* eslint-disable pipedream/required-properties-description */ +/* eslint-disable pipedream/required-properties-version */ +/* eslint-disable pipedream/required-properties-type */ +import base from "../../../gmail/actions/add-label-to-email/add-label-to-email.mjs"; +import overrideApp from "../../common/override-app.mjs"; + +overrideApp(base); + +export default { + ...base, + key: "gmail_custom_oauth-add-label-to-email", +}; diff --git a/components/gmail_custom_oauth/actions/send-email/send-email.mjs b/components/gmail_custom_oauth/actions/send-email/send-email.mjs new file mode 100644 index 0000000000000..ca65544e0f519 --- /dev/null +++ b/components/gmail_custom_oauth/actions/send-email/send-email.mjs @@ -0,0 +1,13 @@ +/* eslint-disable pipedream/required-properties-name */ +/* eslint-disable pipedream/required-properties-description */ +/* eslint-disable pipedream/required-properties-version */ +/* eslint-disable pipedream/required-properties-type */ +import base from "../../../gmail/actions/send-email/send-email.mjs"; +import overrideApp from "../../common/override-app.mjs"; + +overrideApp(base); + +export default { + ...base, + key: "gmail_custom_oauth-send-email", +}; diff --git a/components/gmail_custom_oauth/app/gmail_custom_oauth.app.ts b/components/gmail_custom_oauth/app/gmail_custom_oauth.app.ts deleted file mode 100644 index 0dab99002b153..0000000000000 --- a/components/gmail_custom_oauth/app/gmail_custom_oauth.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "gmail_custom_oauth", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); \ No newline at end of file diff --git a/components/gmail_custom_oauth/common/override-app.mjs b/components/gmail_custom_oauth/common/override-app.mjs new file mode 100644 index 0000000000000..eaf83ad061027 --- /dev/null +++ b/components/gmail_custom_oauth/common/override-app.mjs @@ -0,0 +1,23 @@ +import app from "../gmail_custom_oauth.app.mjs"; +const appName = "gmail"; + +/** + * This function substitutes the app so that $auth and propDefinitions correspond to the correct app + * This is done to avoid duplicating code because all component props and methods are shared between + * gorgias_oauth and gorgias (api_key) apps + * @param {*} base app to inject - in this case, gorgias_oauth + */ +function overrideApp(base) { + base.props[appName] = app; + + Object.keys(base.props) + .filter((prop) => prop != appName) + .forEach((prop) => { + const { propDefinition } = base.props[prop]; + if (propDefinition?.length > 0) { + propDefinition[0] = app; + } + }); +} + +export default overrideApp; diff --git a/components/gmail_custom_oauth/gmail_custom_oauth.app.mjs b/components/gmail_custom_oauth/gmail_custom_oauth.app.mjs new file mode 100644 index 0000000000000..c260cee3f9d61 --- /dev/null +++ b/components/gmail_custom_oauth/gmail_custom_oauth.app.mjs @@ -0,0 +1,23 @@ +import base from "../gmail/gmail.app.mjs"; +import gmail from "@googleapis/gmail"; + +export default { + ...base, + type: "app", + app: "gmail_custom_oauth", + methods: { + _accessToken(){ + return this.$auth.oauth_access_token; + }, + _client() { + const auth = new gmail.auth.OAuth2(); + auth.setCredentials({ + access_token: this._accessToken(), + }); + return gmail.gmail({ + version: "v1", + auth, + }); + }, + }, +}; diff --git a/components/gmail_custom_oauth/package.json b/components/gmail_custom_oauth/package.json index b7835392763e2..3dad458a5a797 100644 --- a/components/gmail_custom_oauth/package.json +++ b/components/gmail_custom_oauth/package.json @@ -7,11 +7,16 @@ "pipedream", "gmail_custom_oauth" ], - "files": ["dist"], "homepage": "https://pipedream.com/apps/gmail_custom_oauth", "author": "Pipedream (https://pipedream.com/)", "license": "MIT", "publishConfig": { "access": "public" + }, + "dependencies": { + "@googleapis/gmail": "^0.3.4", + "@pipedream/platform": "^1.1.1", + "html-to-text": "^8.2.1", + "nodemailer": "^6.7.8" } -} \ No newline at end of file +} diff --git a/components/gmail_custom_oauth/sources/new-attachment/new-attachment.mjs b/components/gmail_custom_oauth/sources/new-attachment/new-attachment.mjs new file mode 100644 index 0000000000000..6183329439b7e --- /dev/null +++ b/components/gmail_custom_oauth/sources/new-attachment/new-attachment.mjs @@ -0,0 +1,13 @@ +/* eslint-disable pipedream/required-properties-name */ +/* eslint-disable pipedream/required-properties-description */ +/* eslint-disable pipedream/required-properties-version */ +/* eslint-disable pipedream/required-properties-type */ +import base from "../../../gmail/sources/new-attachment/new-attachment.mjs"; +import overrideApp from "../../common/override-app.mjs"; + +overrideApp(base); + +export default { + ...base, + key: "gmail_custom_oauth-new-attachment", +}; diff --git a/components/gmail_custom_oauth/sources/new-email/new-email.mjs b/components/gmail_custom_oauth/sources/new-email/new-email.mjs new file mode 100644 index 0000000000000..5b5333204b27d --- /dev/null +++ b/components/gmail_custom_oauth/sources/new-email/new-email.mjs @@ -0,0 +1,13 @@ +/* eslint-disable pipedream/required-properties-name */ +/* eslint-disable pipedream/required-properties-description */ +/* eslint-disable pipedream/required-properties-version */ +/* eslint-disable pipedream/required-properties-type */ +import base from "../../../gmail/sources/new-email/new-email.mjs"; +import overrideApp from "../../common/override-app.mjs"; + +overrideApp(base); + +export default { + ...base, + key: "gmail_custom_oauth-new-email", +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24c8378a867a6..0393e6c58ffcb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -61,6 +61,12 @@ importers: tsc-watch: 5.0.3_typescript@4.7.4 typescript: 4.7.4 + components/action_builder: + specifiers: {} + + components/action_network: + specifiers: {} + components/activecampaign: specifiers: '@pipedream/platform': ^0.9.0 @@ -706,6 +712,18 @@ importers: html-to-text: 8.2.1 nodemailer: 6.7.8 + components/gmail_custom_oauth: + specifiers: + '@googleapis/gmail': ^0.3.4 + '@pipedream/platform': ^1.1.1 + html-to-text: ^8.2.1 + nodemailer: ^6.7.8 + dependencies: + '@googleapis/gmail': 0.3.4 + '@pipedream/platform': 1.1.1 + html-to-text: 8.2.1 + nodemailer: 6.7.8 + components/gobio_link: specifiers: {}