Compare commits
2 Commits
gmail-inte
...
AUT-796
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dff1c5e387 | ||
![]() |
9b51e0f746 |
52
packages/backend/src/apps/firebase/assets/favicon.svg
Normal file
52
packages/backend/src/apps/firebase/assets/favicon.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 21 KiB |
@@ -11,7 +11,7 @@ export default {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
value: '{WEB_APP_URL}/app/gmail/connections/add',
|
value: '{WEB_APP_URL}/app/firebase/connections/add',
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
description:
|
description:
|
||||||
'When asked to input a redirect URL in Google Cloud, enter the URL above.',
|
'When asked to input a redirect URL in Google Cloud, enter the URL above.',
|
||||||
@@ -39,6 +39,29 @@ export default {
|
|||||||
description: null,
|
description: null,
|
||||||
clickToCopy: false,
|
clickToCopy: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'projectId',
|
||||||
|
label: 'Project ID',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description: 'The project id of your Firebase project',
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'realtimeDatabaseId',
|
||||||
|
label: 'Realtime Database Domain',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description:
|
||||||
|
'If you want to use Realtime Database, please provide the domain of your Realtime Database (https://{{domain}}.firebaseio.com)',
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
generateAuthUrl,
|
generateAuthUrl,
|
@@ -12,7 +12,12 @@ const refreshToken = async ($) => {
|
|||||||
|
|
||||||
const { data } = await $.http.post(
|
const { data } = await $.http.post(
|
||||||
'https://oauth2.googleapis.com/token',
|
'https://oauth2.googleapis.com/token',
|
||||||
params.toString()
|
params.toString(),
|
||||||
|
{
|
||||||
|
additionalProperties: {
|
||||||
|
skipAddingAuthHeader: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
await $.auth.set({
|
await $.auth.set({
|
@@ -5,13 +5,21 @@ const verifyCredentials = async ($) => {
|
|||||||
(field) => field.key == 'oAuthRedirectUrl'
|
(field) => field.key == 'oAuthRedirectUrl'
|
||||||
);
|
);
|
||||||
const redirectUri = oauthRedirectUrlField.value;
|
const redirectUri = oauthRedirectUrlField.value;
|
||||||
const { data } = await $.http.post(`https://oauth2.googleapis.com/token`, {
|
const { data } = await $.http.post(
|
||||||
|
`https://oauth2.googleapis.com/token`,
|
||||||
|
{
|
||||||
client_id: $.auth.data.clientId,
|
client_id: $.auth.data.clientId,
|
||||||
client_secret: $.auth.data.clientSecret,
|
client_secret: $.auth.data.clientSecret,
|
||||||
code: $.auth.data.code,
|
code: $.auth.data.code,
|
||||||
grant_type: 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
redirect_uri: redirectUri,
|
redirect_uri: redirectUri,
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
additionalProperties: {
|
||||||
|
skipAddingAuthHeader: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
await $.auth.set({
|
await $.auth.set({
|
||||||
accessToken: data.access_token,
|
accessToken: data.access_token,
|
@@ -1,6 +1,7 @@
|
|||||||
const authScope = [
|
const authScope = [
|
||||||
'https://www.googleapis.com/auth/gmail.compose',
|
'https://www.googleapis.com/auth/datastore',
|
||||||
'https://www.googleapis.com/auth/gmail.modify',
|
'https://www.googleapis.com/auth/firebase.database',
|
||||||
|
'https://www.googleapis.com/auth/datastore',
|
||||||
'https://www.googleapis.com/auth/userinfo.email',
|
'https://www.googleapis.com/auth/userinfo.email',
|
||||||
'https://www.googleapis.com/auth/userinfo.profile',
|
'https://www.googleapis.com/auth/userinfo.profile',
|
||||||
];
|
];
|
@@ -1,6 +1,11 @@
|
|||||||
const getCurrentUser = async ($) => {
|
const getCurrentUser = async ($) => {
|
||||||
const { data: currentUser } = await $.http.get(
|
const { data: currentUser } = await $.http.get(
|
||||||
'https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses'
|
'https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses',
|
||||||
|
{
|
||||||
|
additionalProperties: {
|
||||||
|
skipAddingAuthHeader: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
);
|
);
|
||||||
return currentUser;
|
return currentUser;
|
||||||
};
|
};
|
16
packages/backend/src/apps/firebase/common/set-base-url.js
Normal file
16
packages/backend/src/apps/firebase/common/set-base-url.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const setBaseUrl = ($, requestConfig) => {
|
||||||
|
const realtimeDatabaseId = $.auth.data.realtimeDatabaseId;
|
||||||
|
|
||||||
|
if (requestConfig.additionalProperties?.skipAddingAuthHeader)
|
||||||
|
return requestConfig;
|
||||||
|
|
||||||
|
if (requestConfig.additionalProperties?.setFirestoreBaseUrl) {
|
||||||
|
requestConfig.baseURL = 'https://firestore.googleapis.com';
|
||||||
|
} else {
|
||||||
|
requestConfig.baseURL = `https://${realtimeDatabaseId}.firebaseio.com`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default setBaseUrl;
|
3
packages/backend/src/apps/firebase/dynamic-data/index.js
Normal file
3
packages/backend/src/apps/firebase/dynamic-data/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import listFirestoreCollections from './list-firestore-collections/index.js';
|
||||||
|
|
||||||
|
export default [listFirestoreCollections];
|
@@ -0,0 +1,32 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List firestore collections',
|
||||||
|
key: 'listFirestoreCollections',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const firestoreCollections = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
const projectId = $.auth.data.projectId;
|
||||||
|
|
||||||
|
const { data } = await $.http.post(
|
||||||
|
`/v1/projects/${projectId}/databases/(default)/documents:listCollectionIds`,
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
additionalProperties: {
|
||||||
|
setFirestoreBaseUrl: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data.collectionIds?.length) {
|
||||||
|
for (const collectionId of data.collectionIds) {
|
||||||
|
firestoreCollections.data.push({
|
||||||
|
value: collectionId,
|
||||||
|
name: collectionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return firestoreCollections;
|
||||||
|
},
|
||||||
|
};
|
21
packages/backend/src/apps/firebase/index.js
Normal file
21
packages/backend/src/apps/firebase/index.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import defineApp from '../../helpers/define-app.js';
|
||||||
|
import addAuthHeader from './common/add-auth-header.js';
|
||||||
|
import auth from './auth/index.js';
|
||||||
|
import setBaseUrl from './common/set-base-url.js';
|
||||||
|
import triggers from './triggers/index.js';
|
||||||
|
import dynamicData from './dynamic-data/index.js';
|
||||||
|
|
||||||
|
export default defineApp({
|
||||||
|
name: 'Firebase',
|
||||||
|
key: 'firebase',
|
||||||
|
baseUrl: 'https://firebase.google.com',
|
||||||
|
apiBaseUrl: '',
|
||||||
|
iconUrl: '{BASE_URL}/apps/firebase/assets/favicon.svg',
|
||||||
|
authDocUrl: 'https://automatisch.io/docs/apps/firebase/connection',
|
||||||
|
primaryColor: 'FFA000',
|
||||||
|
supportsConnections: true,
|
||||||
|
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||||
|
auth,
|
||||||
|
triggers,
|
||||||
|
dynamicData,
|
||||||
|
});
|
3
packages/backend/src/apps/firebase/triggers/index.js
Normal file
3
packages/backend/src/apps/firebase/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import newDocumentsWithinFirestoreCollection from './new-documents-within-firestore-collection/index.js';
|
||||||
|
|
||||||
|
export default [newDocumentsWithinFirestoreCollection];
|
@@ -0,0 +1,66 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'New documents within a firestore collection',
|
||||||
|
key: 'newDocumentsWithinFirestoreCollection',
|
||||||
|
pollInterval: 15,
|
||||||
|
description:
|
||||||
|
'Triggers when a new document is added within a Cloud Firestore collection.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Collection',
|
||||||
|
key: 'collectionId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listFirestoreCollections',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const projectId = $.auth.data.projectId;
|
||||||
|
const collectionId = $.step.parameters.collectionId;
|
||||||
|
const params = {
|
||||||
|
pageSize: 100,
|
||||||
|
pageToken: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
do {
|
||||||
|
const { data } = await $.http.get(
|
||||||
|
`/v1/projects/${projectId}/databases/(default)/documents/${collectionId}`,
|
||||||
|
{
|
||||||
|
params,
|
||||||
|
additionalProperties: {
|
||||||
|
setFirestoreBaseUrl: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
params.pageToken = data.nextPageToken;
|
||||||
|
|
||||||
|
if (!data?.documents?.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const document of data.documents) {
|
||||||
|
const nameParts = document.name.split('/');
|
||||||
|
const id = nameParts[nameParts.length - 1];
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: document,
|
||||||
|
meta: {
|
||||||
|
internalId: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} while (params.pageToken);
|
||||||
|
},
|
||||||
|
});
|
@@ -1,11 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 49.4 512 399.42">
|
|
||||||
<g fill="none" fill-rule="evenodd">
|
|
||||||
<g fill-rule="nonzero">
|
|
||||||
<path fill="#4285f4" d="M34.91 448.818h81.454V251L0 163.727V413.91c0 19.287 15.622 34.91 34.91 34.91z"/>
|
|
||||||
<path fill="#34a853" d="M395.636 448.818h81.455c19.287 0 34.909-15.622 34.909-34.909V163.727L395.636 251z"/>
|
|
||||||
<path fill="#fbbc04" d="M395.636 99.727V251L512 163.727v-46.545c0-43.142-49.25-67.782-83.782-41.891z"/>
|
|
||||||
</g>
|
|
||||||
<path fill="#ea4335" d="M116.364 251V99.727L256 204.455 395.636 99.727V251L256 355.727z"/>
|
|
||||||
<path fill="#c5221f" fill-rule="nonzero" d="M0 117.182v46.545L116.364 251V99.727L83.782 75.291C49.25 49.4 0 74.04 0 117.18z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 720 B |
@@ -1,15 +0,0 @@
|
|||||||
import defineApp from '../../helpers/define-app.js';
|
|
||||||
import addAuthHeader from './common/add-auth-header.js';
|
|
||||||
import auth from './auth/index.js';
|
|
||||||
export default defineApp({
|
|
||||||
name: 'Gmail',
|
|
||||||
key: 'gmail',
|
|
||||||
baseUrl: 'https://mail.google.com',
|
|
||||||
apiBaseUrl: 'https://gmail.googleapis.com',
|
|
||||||
iconUrl: '{BASE_URL}/apps/gmail/assets/favicon.svg',
|
|
||||||
authDocUrl: 'https://automatisch.io/docs/apps/gmail/connection',
|
|
||||||
primaryColor: 'ea4335',
|
|
||||||
supportsConnections: true,
|
|
||||||
beforeRequest: [addAuthHeader],
|
|
||||||
auth,
|
|
||||||
});
|
|
@@ -95,6 +95,15 @@ export default defineConfig({
|
|||||||
{ text: 'Connection', link: '/apps/filter/connection' },
|
{ text: 'Connection', link: '/apps/filter/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'Firebase',
|
||||||
|
collapsible: true,
|
||||||
|
collapsed: true,
|
||||||
|
items: [
|
||||||
|
{ text: 'Triggers', link: '/apps/firebase/triggers' },
|
||||||
|
{ text: 'Connection', link: '/apps/firebase/connection' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: 'Flickr',
|
text: 'Flickr',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
@@ -141,12 +150,6 @@ export default defineConfig({
|
|||||||
{ text: 'Connection', link: '/apps/gitlab/connection' },
|
{ text: 'Connection', link: '/apps/gitlab/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
text: 'Gmail',
|
|
||||||
collapsible: true,
|
|
||||||
collapsed: true,
|
|
||||||
items: [{ text: 'Connection', link: '/apps/gmail/connection' }],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
text: 'Google Calendar',
|
text: 'Google Calendar',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# Gmail
|
# Firebase
|
||||||
|
|
||||||
:::info
|
:::info
|
||||||
This page explains the steps you need to follow to set up the Gmail
|
This page explains the steps you need to follow to set up the Firebase
|
||||||
connection in Automatisch. If any of the steps are outdated, please let us know!
|
connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@@ -9,9 +9,9 @@ connection in Automatisch. If any of the steps are outdated, please let us know!
|
|||||||
2. Click on the project drop-down menu at the top of the page, and click on the **New Project** button.
|
2. Click on the project drop-down menu at the top of the page, and click on the **New Project** button.
|
||||||
3. Enter a name for your project and click on the **Create** button.
|
3. Enter a name for your project and click on the **Create** button.
|
||||||
4. Go to [API Library](https://console.cloud.google.com/apis/library) in Google Cloud console.
|
4. Go to [API Library](https://console.cloud.google.com/apis/library) in Google Cloud console.
|
||||||
5. Search for **People API** in the search bar and click on it.
|
5. Search for **Cloud Firestore API** in the search bar and click on it.
|
||||||
6. Click on the **Enable** button to enable the API.
|
6. Click on the **Enable** button to enable the API.
|
||||||
7. Repeat steps 5 and 6 for the **Gmail API**
|
7. Repeat steps 5 and 6 for the **Firebase Realtime Database API and People API**
|
||||||
8. Go to [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) in Google Cloud console.
|
8. Go to [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) in Google Cloud console.
|
||||||
9. Select **External** here for starting your app in testing mode at first. Click on the **Create** button.
|
9. Select **External** here for starting your app in testing mode at first. Click on the **Create** button.
|
||||||
10. Fill **App Name**, **User Support Email**, and **Developer Contact Information**. Click on the **Save and Continue** button.
|
10. Fill **App Name**, **User Support Email**, and **Developer Contact Information**. Click on the **Save and Continue** button.
|
||||||
@@ -24,5 +24,8 @@ connection in Automatisch. If any of the steps are outdated, please let us know!
|
|||||||
17. Copy **OAuth Redirect URL** from Automatisch to **Authorized redirect URIs** field, and click on the **Create** button.
|
17. Copy **OAuth Redirect URL** from Automatisch to **Authorized redirect URIs** field, and click on the **Create** button.
|
||||||
18. Copy the **Your Client ID** value from the following popup to the `Client ID` field on Automatisch.
|
18. Copy the **Your Client ID** value from the following popup to the `Client ID` field on Automatisch.
|
||||||
19. Copy the **Your Client Secret** value from the following popup to the `Client Secret` field on Automatisch.
|
19. Copy the **Your Client Secret** value from the following popup to the `Client Secret` field on Automatisch.
|
||||||
20. Click **Submit** button on Automatisch.
|
20. Login to your [Firebase account](https://firebase.google.com/) and go to your project (please create a new project if you don't already have one).
|
||||||
21. Congrats! Start using your new Gmail connection within the flows.
|
21. Click on the gear icon next to **Project Overview** and go to **Project settings**.
|
||||||
|
22. Copy the **Project ID** value to the `Project ID` field on Automatisch.
|
||||||
|
23. Click **Submit** button on Automatisch.
|
||||||
|
24. Congrats! Start using your new Firebase connection within the flows.
|
12
packages/docs/pages/apps/firebase/triggers.md
Normal file
12
packages/docs/pages/apps/firebase/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/firebase.svg
|
||||||
|
items:
|
||||||
|
- name: New documents within a firestore collection
|
||||||
|
desc: Triggers when a new document is added within a Cloud Firestore collection.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -9,6 +9,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Discord](/apps/discord/actions)
|
- [Discord](/apps/discord/actions)
|
||||||
- [Dropbox](/apps/dropbox/actions)
|
- [Dropbox](/apps/dropbox/actions)
|
||||||
- [Filter](/apps/filter/actions)
|
- [Filter](/apps/filter/actions)
|
||||||
|
- [Firebase](/apps/firebase/triggers)
|
||||||
- [Flickr](/apps/flickr/triggers)
|
- [Flickr](/apps/flickr/triggers)
|
||||||
- [Formatter](/apps/formatter/actions)
|
- [Formatter](/apps/formatter/actions)
|
||||||
- [Ghost](/apps/ghost/triggers)
|
- [Ghost](/apps/ghost/triggers)
|
||||||
|
52
packages/docs/pages/public/favicons/firebase.svg
Normal file
52
packages/docs/pages/public/favicons/firebase.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 21 KiB |
52
packages/docs/pages/public/favicons/firestore.svg
Normal file
52
packages/docs/pages/public/favicons/firestore.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 21 KiB |
@@ -1,11 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 49.4 512 399.42">
|
|
||||||
<g fill="none" fill-rule="evenodd">
|
|
||||||
<g fill-rule="nonzero">
|
|
||||||
<path fill="#4285f4" d="M34.91 448.818h81.454V251L0 163.727V413.91c0 19.287 15.622 34.91 34.91 34.91z"/>
|
|
||||||
<path fill="#34a853" d="M395.636 448.818h81.455c19.287 0 34.909-15.622 34.909-34.909V163.727L395.636 251z"/>
|
|
||||||
<path fill="#fbbc04" d="M395.636 99.727V251L512 163.727v-46.545c0-43.142-49.25-67.782-83.782-41.891z"/>
|
|
||||||
</g>
|
|
||||||
<path fill="#ea4335" d="M116.364 251V99.727L256 204.455 395.636 99.727V251L256 355.727z"/>
|
|
||||||
<path fill="#c5221f" fill-rule="nonzero" d="M0 117.182v46.545L116.364 251V99.727L83.782 75.291C49.25 49.4 0 74.04 0 117.18z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 720 B |
Reference in New Issue
Block a user