diff --git a/packages/backend/src/apps/monday/assets/favicon.svg b/packages/backend/src/apps/monday/assets/favicon.svg new file mode 100644 index 00000000..5d46afcf --- /dev/null +++ b/packages/backend/src/apps/monday/assets/favicon.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/packages/backend/src/apps/monday/auth/index.js b/packages/backend/src/apps/monday/auth/index.js new file mode 100644 index 00000000..f1280da5 --- /dev/null +++ b/packages/backend/src/apps/monday/auth/index.js @@ -0,0 +1,21 @@ +import verifyCredentials from './verify-credentials.js'; +import isStillVerified from './is-still-verified.js'; + +export default { + fields: [ + { + key: 'apiToken', + label: 'API Token', + type: 'string', + required: true, + readOnly: false, + value: null, + placeholder: null, + description: 'Monday.com API token of your account.', + clickToCopy: false, + }, + ], + + verifyCredentials, + isStillVerified, +}; diff --git a/packages/backend/src/apps/monday/auth/is-still-verified.js b/packages/backend/src/apps/monday/auth/is-still-verified.js new file mode 100644 index 00000000..6663679a --- /dev/null +++ b/packages/backend/src/apps/monday/auth/is-still-verified.js @@ -0,0 +1,8 @@ +import verifyCredentials from './verify-credentials.js'; + +const isStillVerified = async ($) => { + await verifyCredentials($); + return true; +}; + +export default isStillVerified; diff --git a/packages/backend/src/apps/monday/auth/verify-credentials.js b/packages/backend/src/apps/monday/auth/verify-credentials.js new file mode 100644 index 00000000..7b3b05e4 --- /dev/null +++ b/packages/backend/src/apps/monday/auth/verify-credentials.js @@ -0,0 +1,18 @@ +const verifyCredentials = async ($) => { + const body = { + query: 'query { me { name, email } }', + }; + + const { data } = await $.http.post('/', body); + + const screenName = [data.data.me.name, data.data.me.email] + .filter(Boolean) + .join(' @ '); + + await $.auth.set({ + screenName, + apiToken: $.auth.data.apiToken, + }); +}; + +export default verifyCredentials; diff --git a/packages/backend/src/apps/monday/common/add-auth-header.js b/packages/backend/src/apps/monday/common/add-auth-header.js new file mode 100644 index 00000000..19f25cc5 --- /dev/null +++ b/packages/backend/src/apps/monday/common/add-auth-header.js @@ -0,0 +1,9 @@ +const addAuthHeader = ($, requestConfig) => { + if ($.auth.data?.apiToken) { + requestConfig.headers.Authorization = $.auth.data.apiToken; + } + + return requestConfig; +}; + +export default addAuthHeader; diff --git a/packages/backend/src/apps/monday/index.js b/packages/backend/src/apps/monday/index.js new file mode 100644 index 00000000..efed1eae --- /dev/null +++ b/packages/backend/src/apps/monday/index.js @@ -0,0 +1,16 @@ +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: 'Monday', + key: 'monday', + iconUrl: '{BASE_URL}/apps/monday/assets/favicon.svg', + authDocUrl: '{DOCS_URL}/apps/monday/connection', + supportsConnections: true, + baseUrl: 'https://monday.com', + apiBaseUrl: 'https://api.monday.com/v2', + primaryColor: 'F62B54', + beforeRequest: [addAuthHeader], + auth, +}); diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js index 6e9d171f..e3b2afec 100644 --- a/packages/docs/pages/.vitepress/config.js +++ b/packages/docs/pages/.vitepress/config.js @@ -224,6 +224,12 @@ export default defineConfig({ { text: 'Connection', link: '/apps/miro/connection' }, ], }, + { + text: 'Monday', + collapsible: true, + collapsed: true, + items: [{ text: 'Connection', link: '/apps/monday/connection' }], + }, { text: 'Notion', collapsible: true, diff --git a/packages/docs/pages/apps/monday/connection.md b/packages/docs/pages/apps/monday/connection.md new file mode 100644 index 00000000..2087dcd9 --- /dev/null +++ b/packages/docs/pages/apps/monday/connection.md @@ -0,0 +1,12 @@ +# Monday + +:::info +This page explains the steps you need to follow to set up the Monday +connection in Automatisch. If any of the steps are outdated, please let us know! +::: + +1. Login to your Monday account: [https://monday.com](https://monday.com). +2. Click on the account logo and go to the **Developers** page. +3. Click on the **My access tokens** tab on the left. +4. Click on the **Show** button and copy the access token from the page to the `API Token` field on Automatisch. +5. Now, you can start using the Monday connection with Automatisch. diff --git a/packages/docs/pages/public/favicons/monday.svg b/packages/docs/pages/public/favicons/monday.svg new file mode 100644 index 00000000..5d46afcf --- /dev/null +++ b/packages/docs/pages/public/favicons/monday.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file