Compare commits
22 Commits
formatter-
...
gh-actions
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dcc62c3233 | ||
![]() |
e43c083d50 | ||
![]() |
3cd9bdc1d4 | ||
![]() |
c0b8e6178d | ||
![]() |
410f9d0af5 | ||
![]() |
b1fedf28dc | ||
![]() |
b0df03dcd2 | ||
![]() |
2794e50a19 | ||
![]() |
365ae656f2 | ||
![]() |
98649dcba6 | ||
![]() |
213c8096d2 | ||
![]() |
398938f27e | ||
![]() |
6378e62645 | ||
![]() |
251885d4be | ||
![]() |
f53909355f | ||
![]() |
242b68889a | ||
![]() |
6a66b65f2a | ||
![]() |
f30ead6bcb | ||
![]() |
237ee72ca6 | ||
![]() |
3590d84ad6 | ||
![]() |
2dae8c162d | ||
![]() |
9a192b708e |
@@ -1,6 +1,5 @@
|
||||
import text from './text';
|
||||
import numbers from './numbers';
|
||||
import dateTime from './date-time';
|
||||
import utilities from './utilities';
|
||||
|
||||
export default [text, numbers, dateTime, utilities];
|
||||
export default [text, numbers, dateTime];
|
||||
|
@@ -1,54 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
import findArrayItemByProperty from './transformers/find-array-item-by-property';
|
||||
|
||||
const transformers = {
|
||||
findArrayItemByProperty,
|
||||
};
|
||||
|
||||
export default defineAction({
|
||||
name: 'Utilities',
|
||||
key: 'utilities',
|
||||
description: 'Specific utilities to help you transform your data.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Transform',
|
||||
key: 'transform',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Find Array Item By Property',
|
||||
value: 'findArrayItemByProperty',
|
||||
},
|
||||
],
|
||||
additionalFields: {
|
||||
type: 'query',
|
||||
name: 'getDynamicFields',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listTransformOptions',
|
||||
},
|
||||
{
|
||||
name: 'parameters.transform',
|
||||
value: '{parameters.transform}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const transformerName = $.step.parameters
|
||||
.transform as keyof typeof transformers;
|
||||
const output = transformers[transformerName]($);
|
||||
|
||||
$.setActionItem({
|
||||
raw: {
|
||||
output,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,13 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { find } from 'lodash';
|
||||
|
||||
const findArrayItemByProperty = ($: IGlobalVariable) => {
|
||||
const value = JSON.parse($.step.parameters.value as string);
|
||||
const propertyName = $.step.parameters.propertyName as string;
|
||||
const propertyValue = $.step.parameters.propertyValue as string;
|
||||
|
||||
const foundItem = find(value, { [propertyName]: propertyValue });
|
||||
return foundItem;
|
||||
};
|
||||
|
||||
export default findArrayItemByProperty;
|
@@ -2,35 +2,33 @@ import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
import capitalize from './text/capitalize';
|
||||
import extractEmailAddress from './text/extract-email-address';
|
||||
import extractNumber from './text/extract-number';
|
||||
import findArrayItemByProperty from './utilities/find-array-item-by-property';
|
||||
import formatDateTime from './date-time/format-date-time';
|
||||
import formatNumber from './numbers/format-number';
|
||||
import htmlToMarkdown from './text/html-to-markdown';
|
||||
import lowercase from './text/lowercase';
|
||||
import markdownToHtml from './text/markdown-to-html';
|
||||
import performMathOperation from './numbers/perform-math-operation';
|
||||
import pluralize from './text/pluralize';
|
||||
import randomNumber from './numbers/random-number';
|
||||
import replace from './text/replace';
|
||||
import trimWhitespace from './text/trim-whitespace';
|
||||
import useDefaultValue from './text/use-default-value';
|
||||
import performMathOperation from './numbers/perform-math-operation';
|
||||
import randomNumber from './numbers/random-number';
|
||||
import formatNumber from './numbers/format-number';
|
||||
import formatDateTime from './date-time/format-date-time';
|
||||
|
||||
const options: IJSONObject = {
|
||||
capitalize,
|
||||
extractEmailAddress,
|
||||
extractNumber,
|
||||
findArrayItemByProperty,
|
||||
formatDateTime,
|
||||
formatNumber,
|
||||
htmlToMarkdown,
|
||||
lowercase,
|
||||
markdownToHtml,
|
||||
performMathOperation,
|
||||
pluralize,
|
||||
randomNumber,
|
||||
replace,
|
||||
trimWhitespace,
|
||||
useDefaultValue,
|
||||
performMathOperation,
|
||||
randomNumber,
|
||||
formatNumber,
|
||||
formatDateTime,
|
||||
};
|
||||
|
||||
export default {
|
||||
|
@@ -1,28 +0,0 @@
|
||||
const findArrayItemByProperty = [
|
||||
{
|
||||
label: 'Value',
|
||||
key: 'value',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Array of objects that will be searched.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Property Name',
|
||||
key: 'propertyName',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Property name that will be searched.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Property Value',
|
||||
key: 'propertyValue',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Property value that will be matched.',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default findArrayItemByProperty;
|
27
packages/backend/src/apps/google-calendar/assets/favicon.svg
Normal file
27
packages/backend/src/apps/google-calendar/assets/favicon.svg
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg version="1.1" id="Livello_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
|
||||
<g>
|
||||
<g transform="translate(3.75 3.75)">
|
||||
<path fill="#FFFFFF" d="M148.882,43.618l-47.368-5.263l-57.895,5.263L38.355,96.25l5.263,52.632l52.632,6.579l52.632-6.579
|
||||
l5.263-53.947L148.882,43.618z"/>
|
||||
<path fill="#1A73E8" d="M65.211,125.276c-3.934-2.658-6.658-6.539-8.145-11.671l9.132-3.763c0.829,3.158,2.276,5.605,4.342,7.342
|
||||
c2.053,1.737,4.553,2.592,7.474,2.592c2.987,0,5.553-0.908,7.697-2.724s3.224-4.132,3.224-6.934c0-2.868-1.132-5.211-3.395-7.026
|
||||
s-5.105-2.724-8.5-2.724h-5.276v-9.039H76.5c2.921,0,5.382-0.789,7.382-2.368c2-1.579,3-3.737,3-6.487
|
||||
c0-2.447-0.895-4.395-2.684-5.855s-4.053-2.197-6.803-2.197c-2.684,0-4.816,0.711-6.395,2.145s-2.724,3.197-3.447,5.276
|
||||
l-9.039-3.763c1.197-3.395,3.395-6.395,6.618-8.987c3.224-2.592,7.342-3.895,12.342-3.895c3.697,0,7.026,0.711,9.974,2.145
|
||||
c2.947,1.434,5.263,3.421,6.934,5.947c1.671,2.539,2.5,5.382,2.5,8.539c0,3.224-0.776,5.947-2.329,8.184
|
||||
c-1.553,2.237-3.461,3.947-5.724,5.145v0.539c2.987,1.25,5.421,3.158,7.342,5.724c1.908,2.566,2.868,5.632,2.868,9.211
|
||||
s-0.908,6.776-2.724,9.579c-1.816,2.803-4.329,5.013-7.513,6.618c-3.197,1.605-6.789,2.421-10.776,2.421
|
||||
C73.408,129.263,69.145,127.934,65.211,125.276z"/>
|
||||
<path fill="#1A73E8" d="M121.25,79.961l-9.974,7.25l-5.013-7.605l17.987-12.974h6.895v61.197h-9.895L121.25,79.961z"/>
|
||||
<path fill="#EA4335" d="M148.882,196.25l47.368-47.368l-23.684-10.526l-23.684,10.526l-10.526,23.684L148.882,196.25z"/>
|
||||
<path fill="#34A853" d="M33.092,172.566l10.526,23.684h105.263v-47.368H43.618L33.092,172.566z"/>
|
||||
<path fill="#4285F4" d="M12.039-3.75C3.316-3.75-3.75,3.316-3.75,12.039v136.842l23.684,10.526l23.684-10.526V43.618h105.263
|
||||
l10.526-23.684L148.882-3.75H12.039z"/>
|
||||
<path fill="#188038" d="M-3.75,148.882v31.579c0,8.724,7.066,15.789,15.789,15.789h31.579v-47.368H-3.75z"/>
|
||||
<path fill="#FBBC04" d="M148.882,43.618v105.263h47.368V43.618l-23.684-10.526L148.882,43.618z"/>
|
||||
<path fill="#1967D2" d="M196.25,43.618V12.039c0-8.724-7.066-15.789-15.789-15.789h-31.579v47.368H196.25z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,24 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import authScope from '../common/auth-scope';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId as string,
|
||||
redirect_uri: redirectUri,
|
||||
prompt: 'select_account',
|
||||
scope: authScope.join(' '),
|
||||
response_type: 'code',
|
||||
access_type: 'offline',
|
||||
});
|
||||
|
||||
const url = `https://accounts.google.com/o/oauth2/v2/auth?${searchParams.toString()}`;
|
||||
|
||||
await $.auth.set({
|
||||
url,
|
||||
});
|
||||
}
|
48
packages/backend/src/apps/google-calendar/auth/index.ts
Normal file
48
packages/backend/src/apps/google-calendar/auth/index.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import refreshToken from './refresh-token';
|
||||
import isStillVerified from './is-still-verified';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/google-calendar/connections/add',
|
||||
placeholder: null,
|
||||
description:
|
||||
'When asked to input a redirect URL in Google Cloud, enter the URL above.',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
generateAuthUrl,
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
refreshToken,
|
||||
};
|
@@ -0,0 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
return !!currentUser.resourceName;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -0,0 +1,26 @@
|
||||
import { URLSearchParams } from 'node:url';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import authScope from '../common/auth-scope';
|
||||
|
||||
const refreshToken = async ($: IGlobalVariable) => {
|
||||
const params = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId as string,
|
||||
client_secret: $.auth.data.clientSecret as string,
|
||||
grant_type: 'refresh_token',
|
||||
refresh_token: $.auth.data.refreshToken as string,
|
||||
});
|
||||
|
||||
const { data } = await $.http.post(
|
||||
'https://oauth2.googleapis.com/token',
|
||||
params.toString()
|
||||
);
|
||||
|
||||
await $.auth.set({
|
||||
accessToken: data.access_token,
|
||||
expiresIn: data.expires_in,
|
||||
scope: authScope.join(' '),
|
||||
tokenType: data.token_type,
|
||||
});
|
||||
};
|
||||
|
||||
export default refreshToken;
|
@@ -0,0 +1,57 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
type TUser = {
|
||||
displayName: string;
|
||||
metadata: {
|
||||
primary: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
type TEmailAddress = {
|
||||
value: string;
|
||||
metadata: {
|
||||
primary: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const { data } = await $.http.post(`https://oauth2.googleapis.com/token`, {
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
||||
await $.auth.set({
|
||||
accessToken: data.access_token,
|
||||
tokenType: data.token_type,
|
||||
});
|
||||
|
||||
const currentUser = await getCurrentUser($);
|
||||
|
||||
const { displayName } = currentUser.names.find(
|
||||
(name: TUser) => name.metadata.primary
|
||||
);
|
||||
const { value: email } = currentUser.emailAddresses.find(
|
||||
(emailAddress: TEmailAddress) => emailAddress.metadata.primary
|
||||
);
|
||||
|
||||
await $.auth.set({
|
||||
clientId: $.auth.data.clientId,
|
||||
clientSecret: $.auth.data.clientSecret,
|
||||
scope: $.auth.data.scope,
|
||||
idToken: data.id_token,
|
||||
expiresIn: data.expires_in,
|
||||
refreshToken: data.refresh_token,
|
||||
resourceName: currentUser.resourceName,
|
||||
screenName: `${displayName} - ${email}`,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -0,0 +1,11 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data?.accessToken) {
|
||||
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -0,0 +1,7 @@
|
||||
const authScope: string[] = [
|
||||
'https://www.googleapis.com/auth/calendar',
|
||||
'https://www.googleapis.com/auth/userinfo.email',
|
||||
'https://www.googleapis.com/auth/userinfo.profile',
|
||||
];
|
||||
|
||||
export default authScope;
|
@@ -0,0 +1,10 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable) => {
|
||||
const { data: currentUser } = await $.http.get(
|
||||
'https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses'
|
||||
);
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
@@ -0,0 +1,3 @@
|
||||
import listCalendars from './list-calendars';
|
||||
|
||||
export default [listCalendars];
|
@@ -0,0 +1,36 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List calendars',
|
||||
key: 'listCalendars',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const drives: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const params = {
|
||||
pageToken: undefined as unknown as string,
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get(`/v3/users/me/calendarList`, {
|
||||
params,
|
||||
});
|
||||
params.pageToken = data.nextPageToken;
|
||||
|
||||
if (data.items) {
|
||||
for (const calendar of data.items) {
|
||||
drives.data.push({
|
||||
value: calendar.id,
|
||||
name: calendar.summary,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.pageToken);
|
||||
|
||||
return drives;
|
||||
},
|
||||
};
|
0
packages/backend/src/apps/google-calendar/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/google-calendar/index.d.ts
vendored
Normal file
20
packages/backend/src/apps/google-calendar/index.ts
Normal file
20
packages/backend/src/apps/google-calendar/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import triggers from './triggers';
|
||||
import dynamicData from './dynamic-data';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Google Calendar',
|
||||
key: 'google-calendar',
|
||||
baseUrl: 'https://calendar.google.com',
|
||||
apiBaseUrl: 'https://www.googleapis.com/calendar',
|
||||
iconUrl: '{BASE_URL}/apps/google-calendar/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/google-calendar/connection',
|
||||
primaryColor: '448AFF',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
dynamicData,
|
||||
});
|
@@ -0,0 +1,4 @@
|
||||
import newCalendar from './new-calendar';
|
||||
import newEvent from './new-event';
|
||||
|
||||
export default [newCalendar, newEvent];
|
@@ -0,0 +1,34 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New calendar',
|
||||
key: 'newCalendar',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new calendar is created.',
|
||||
arguments: [],
|
||||
|
||||
async run($) {
|
||||
const params: Record<string, unknown> = {
|
||||
pageToken: undefined as unknown as string,
|
||||
maxResults: 250,
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get('/v3/users/me/calendarList', {
|
||||
params,
|
||||
});
|
||||
params.pageToken = data.nextPageToken;
|
||||
|
||||
if (data.items?.length) {
|
||||
for (const calendar of data.items.reverse()) {
|
||||
$.pushTriggerItem({
|
||||
raw: calendar,
|
||||
meta: {
|
||||
internalId: calendar.etag,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.pageToken);
|
||||
},
|
||||
});
|
@@ -0,0 +1,55 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New event',
|
||||
key: 'newEvent',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new event is created.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Calendar',
|
||||
key: 'calendarId',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: '',
|
||||
variables: false,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listCalendars',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const calendarId = $.step.parameters.calendarId;
|
||||
|
||||
const params: Record<string, unknown> = {
|
||||
pageToken: undefined as unknown as string,
|
||||
orderBy: 'updated',
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get(`/v3/calendars/${calendarId}/events`, {
|
||||
params,
|
||||
});
|
||||
params.pageToken = data.nextPageToken;
|
||||
|
||||
if (data.items?.length) {
|
||||
for (const event of data.items.reverse()) {
|
||||
$.pushTriggerItem({
|
||||
raw: event,
|
||||
meta: {
|
||||
internalId: event.etag,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.pageToken);
|
||||
},
|
||||
});
|
1
packages/backend/src/apps/pipedrive/assets/favicon.svg
Normal file
1
packages/backend/src/apps/pipedrive/assets/favicon.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32" fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_503_588)" fill="#017737"><path d="M32 16C32 24.8366 24.8366 32 16 32C7.16344 32 0 24.8366 0 16C0 7.16344 7.16344 0 16 0C24.8366 0 32 7.16344 32 16Z" fill="#017737"></path><path d="M24.9842 13.4564C24.9842 17.8851 22.1247 20.914 18.036 20.914C16.0923 20.914 14.4903 20.1136 13.8906 19.1134L13.9189 20.142V26.4847H9.74512V10.0846C9.74512 9.85644 9.68836 9.79843 9.4304 9.79843H8V6.31321H11.4889C13.0896 6.31321 13.4907 7.68461 13.6042 8.28525C14.2337 7.22834 15.8911 6 18.2359 6C22.2679 5.99871 24.9842 8.99802 24.9842 13.4564ZM20.724 13.4847C20.724 11.1131 19.1801 9.48523 17.2351 9.48523C15.6344 9.48523 13.8325 10.5421 13.8325 13.5144C13.8325 15.4568 14.9186 17.4855 17.1783 17.4855C18.837 17.4842 20.724 16.2843 20.724 13.4847Z" fill="#FFFFFF"></path></g></svg>
|
After Width: | Height: | Size: 929 B |
@@ -0,0 +1,19 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId as string,
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
||||
const url = `https://oauth.pipedrive.com/oauth/authorize?${searchParams.toString()}`;
|
||||
|
||||
await $.auth.set({
|
||||
url,
|
||||
});
|
||||
}
|
48
packages/backend/src/apps/pipedrive/auth/index.ts
Normal file
48
packages/backend/src/apps/pipedrive/auth/index.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import refreshToken from './refresh-token';
|
||||
import isStillVerified from './is-still-verified';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/pipedrive/connections/add',
|
||||
placeholder: null,
|
||||
description:
|
||||
'When asked to input a redirect URL in Pipedrive, enter the URL above.',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
generateAuthUrl,
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
refreshToken,
|
||||
};
|
@@ -0,0 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
return !!currentUser;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
33
packages/backend/src/apps/pipedrive/auth/refresh-token.ts
Normal file
33
packages/backend/src/apps/pipedrive/auth/refresh-token.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { URLSearchParams } from 'node:url';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const refreshToken = async ($: IGlobalVariable) => {
|
||||
const params = new URLSearchParams({
|
||||
grant_type: 'refresh_token',
|
||||
refresh_token: $.auth.data.refreshToken as string,
|
||||
});
|
||||
|
||||
const headers = {
|
||||
Authorization: `Basic ${Buffer.from(
|
||||
$.auth.data.clientId + ':' + $.auth.data.clientSecret
|
||||
).toString('base64')}`,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
};
|
||||
|
||||
const response = await $.http.post(
|
||||
'https://oauth.pipedrive.com/oauth/token',
|
||||
params.toString(),
|
||||
{
|
||||
headers,
|
||||
}
|
||||
);
|
||||
|
||||
await $.auth.set({
|
||||
accessToken: response.data.access_token,
|
||||
refreshToken: response.data.refresh_token,
|
||||
tokenType: response.data.token_type,
|
||||
expiresIn: response.data.expires_in,
|
||||
});
|
||||
};
|
||||
|
||||
export default refreshToken;
|
@@ -0,0 +1,59 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const params = new URLSearchParams({
|
||||
grant_type: 'authorization_code',
|
||||
code: $.auth.data.code as string,
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
||||
const headers = {
|
||||
Authorization: `Basic ${Buffer.from(
|
||||
$.auth.data.clientId + ':' + $.auth.data.clientSecret
|
||||
).toString('base64')}`,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
};
|
||||
|
||||
const response = await $.http.post(
|
||||
`https://oauth.pipedrive.com/oauth/token`,
|
||||
params.toString(),
|
||||
{ headers }
|
||||
);
|
||||
|
||||
const {
|
||||
access_token: accessToken,
|
||||
api_domain: apiDomain,
|
||||
expires_in: expiresIn,
|
||||
refresh_token: refreshToken,
|
||||
scope: scope,
|
||||
token_type: tokenType,
|
||||
} = response.data;
|
||||
|
||||
await $.auth.set({
|
||||
accessToken,
|
||||
apiDomain,
|
||||
expiresIn,
|
||||
refreshToken,
|
||||
scope,
|
||||
tokenType,
|
||||
});
|
||||
|
||||
const user = await getCurrentUser($);
|
||||
|
||||
const screenName = [user.name, user.company_domain]
|
||||
.filter(Boolean)
|
||||
.join(' @ ');
|
||||
|
||||
await $.auth.set({
|
||||
userId: user.id,
|
||||
screenName,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -0,0 +1,11 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data?.accessToken) {
|
||||
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -0,0 +1,10 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const response = await $.http.get(`${$.auth.data.apiDomain}/api/v1/users/me`);
|
||||
const currentUser = response.data.data;
|
||||
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
0
packages/backend/src/apps/pipedrive/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/pipedrive/index.d.ts
vendored
Normal file
18
packages/backend/src/apps/pipedrive/index.ts
Normal file
18
packages/backend/src/apps/pipedrive/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import triggers from './triggers';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Pipedrive',
|
||||
key: 'pipedrive',
|
||||
baseUrl: '',
|
||||
apiBaseUrl: '',
|
||||
iconUrl: '{BASE_URL}/apps/pipedrive/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/pipedrive/connection',
|
||||
primaryColor: 'FFFFFF',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
});
|
3
packages/backend/src/apps/pipedrive/triggers/index.ts
Normal file
3
packages/backend/src/apps/pipedrive/triggers/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import newDeals from './new-deals';
|
||||
|
||||
export default [newDeals];
|
@@ -0,0 +1,56 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
type Payload = {
|
||||
start: number;
|
||||
limit: number;
|
||||
sort: string;
|
||||
};
|
||||
|
||||
type ResponseData = {
|
||||
data: {
|
||||
id: number;
|
||||
}[];
|
||||
additional_data: {
|
||||
pagination: {
|
||||
next_start: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New deals',
|
||||
key: 'newDeals',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new deal is created.',
|
||||
arguments: [],
|
||||
|
||||
async run($) {
|
||||
const params: Payload = {
|
||||
start: 0,
|
||||
limit: 100,
|
||||
sort: 'add_time DESC',
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get<ResponseData>(
|
||||
`${$.auth.data.apiDomain}/api/v1/deals`,
|
||||
{ params }
|
||||
);
|
||||
|
||||
if (!data?.data?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
params.start = data.additional_data?.pagination?.next_start;
|
||||
|
||||
for (const deal of data.data) {
|
||||
$.pushTriggerItem({
|
||||
raw: deal,
|
||||
meta: {
|
||||
internalId: deal.id.toString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
} while (params.start);
|
||||
},
|
||||
});
|
@@ -131,6 +131,8 @@ const appConfig: AppConfig = {
|
||||
sentryDsn: process.env.SENTRY_DSN,
|
||||
};
|
||||
|
||||
console.log('license', appConfig.licenseKey);
|
||||
|
||||
if (!appConfig.encryptionKey) {
|
||||
throw new Error('ENCRYPTION_KEY environment variable needs to be set!');
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ const createUser = async (_parent: unknown, params: Params, context: Context) =>
|
||||
userPayload.roleId = params.input.role.id;
|
||||
} catch {
|
||||
// void
|
||||
const role = await Role.query().findOne({ key: 'user' });
|
||||
const role = await Role.query().findOne({ key: 'admin' });
|
||||
userPayload.roleId = role.id;
|
||||
}
|
||||
|
||||
|
@@ -114,6 +114,15 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/gitlab/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Google Calendar',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/google-calendar/triggers' },
|
||||
{ text: 'Connection', link: '/apps/google-calendar/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Google Drive',
|
||||
collapsible: true,
|
||||
@@ -206,6 +215,15 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/openai/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Pipedrive',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/pipedrive/triggers' },
|
||||
{ text: 'Connection', link: '/apps/pipedrive/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'PostgreSQL',
|
||||
collapsible: true,
|
||||
|
28
packages/docs/pages/apps/google-calendar/connection.md
Normal file
28
packages/docs/pages/apps/google-calendar/connection.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Google Calendar
|
||||
|
||||
:::info
|
||||
This page explains the steps you need to follow to set up the Google Calendar
|
||||
connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
:::
|
||||
|
||||
1. Go to the [Google Cloud Console](https://console.cloud.google.com) to create a project.
|
||||
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.
|
||||
4. Go to [API Library](https://console.cloud.google.com/apis/library) in Google Cloud console.
|
||||
5. Search for **Google Calendar API** in the search bar and click on it.
|
||||
6. Click on the **Enable** button to enable the API.
|
||||
7. Repeat steps 5 and 6 for the **People API**.
|
||||
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.
|
||||
10. Fill **App Name**, **User Support Email**, and **Developer Contact Information**. Click on the **Save and Continue** button.
|
||||
11. Skip adding or removing scopes and click on the **Save and Continue** button.
|
||||
12. Click on the **Add Users** button and add a test email because only test users can access the app while publishing status is set to "Testing".
|
||||
13. Click on the **Save and Continue** button and now you have configured the consent screen.
|
||||
14. Go to [Credentials](https://console.cloud.google.com/apis/credentials) in Google Cloud console.
|
||||
15. Click on the **Create Credentials** button and select the **OAuth client ID** option.
|
||||
16. Select the application type as **Web application** and fill the **Name** field.
|
||||
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.
|
||||
19. Copy the **Your Client Secret** value from the following popup to the `Client Secret` field on Automatisch.
|
||||
20. Click **Submit** button on Automatisch.
|
||||
21. Congrats! Start using your new Google Calendar connection within the flows.
|
14
packages/docs/pages/apps/google-calendar/triggers.md
Normal file
14
packages/docs/pages/apps/google-calendar/triggers.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
favicon: /favicons/google-calendar.svg
|
||||
items:
|
||||
- name: New calendar
|
||||
desc: Triggers when a new calendar is created.
|
||||
- name: New event
|
||||
desc: Triggers when a new event is created.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
17
packages/docs/pages/apps/pipedrive/connection.md
Normal file
17
packages/docs/pages/apps/pipedrive/connection.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Pipedrive
|
||||
|
||||
:::info
|
||||
This page explains the steps you need to follow to set up the Pipedrive
|
||||
connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
:::
|
||||
|
||||
1. Go to [Pipedrive developers page](https://developers.pipedrive.com/).
|
||||
2. Sign up for a **Sandbox account** in order to create an app.
|
||||
3. Click create an app button and then choose **Create private app** option.
|
||||
4. Write any app name to be displayed in Automatisch.
|
||||
5. Copy **OAuth Redirect URL** from Automatisch to **Callback URL** field, and click on the **Save** button.
|
||||
6. Check all options in **OAuth & Access scopes** with full access.
|
||||
7. Click on the **Save** button.
|
||||
8. Copy the **Client ID** value to the `Client ID` field on Automatisch.
|
||||
9. Copy the **Client Secret** value to the `Client Secret` field on Automatisch.
|
||||
10. Start using Pipedrive integration with Automatisch!
|
12
packages/docs/pages/apps/pipedrive/triggers.md
Normal file
12
packages/docs/pages/apps/pipedrive/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/pipedrive.svg
|
||||
items:
|
||||
- name: New deals
|
||||
desc: Triggers when a new deal is created.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -11,6 +11,7 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Formatter](/apps/formatter/actions)
|
||||
- [GitHub](/apps/github/triggers)
|
||||
- [GitLab](/apps/gitlab/triggers)
|
||||
- [Google Calendar](/apps/google-calendar/triggers)
|
||||
- [Google Drive](/apps/google-drive/triggers)
|
||||
- [Google Forms](/apps/google-forms/triggers)
|
||||
- [Google Sheets](/apps/google-sheets/triggers)
|
||||
@@ -21,6 +22,7 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Ntfy](/apps/ntfy/actions)
|
||||
- [Odoo](/apps/odoo/actions)
|
||||
- [OpenAI](/apps/openai/actions)
|
||||
- [Pipedrive](/apps/pipedrive/triggers)
|
||||
- [PostgreSQL](/apps/postgresql/actions)
|
||||
- [RSS](/apps/rss/triggers)
|
||||
- [Salesforce](/apps/salesforce/triggers)
|
||||
|
27
packages/docs/pages/public/favicons/google-calendar.svg
Normal file
27
packages/docs/pages/public/favicons/google-calendar.svg
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg version="1.1" id="Livello_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
|
||||
<g>
|
||||
<g transform="translate(3.75 3.75)">
|
||||
<path fill="#FFFFFF" d="M148.882,43.618l-47.368-5.263l-57.895,5.263L38.355,96.25l5.263,52.632l52.632,6.579l52.632-6.579
|
||||
l5.263-53.947L148.882,43.618z"/>
|
||||
<path fill="#1A73E8" d="M65.211,125.276c-3.934-2.658-6.658-6.539-8.145-11.671l9.132-3.763c0.829,3.158,2.276,5.605,4.342,7.342
|
||||
c2.053,1.737,4.553,2.592,7.474,2.592c2.987,0,5.553-0.908,7.697-2.724s3.224-4.132,3.224-6.934c0-2.868-1.132-5.211-3.395-7.026
|
||||
s-5.105-2.724-8.5-2.724h-5.276v-9.039H76.5c2.921,0,5.382-0.789,7.382-2.368c2-1.579,3-3.737,3-6.487
|
||||
c0-2.447-0.895-4.395-2.684-5.855s-4.053-2.197-6.803-2.197c-2.684,0-4.816,0.711-6.395,2.145s-2.724,3.197-3.447,5.276
|
||||
l-9.039-3.763c1.197-3.395,3.395-6.395,6.618-8.987c3.224-2.592,7.342-3.895,12.342-3.895c3.697,0,7.026,0.711,9.974,2.145
|
||||
c2.947,1.434,5.263,3.421,6.934,5.947c1.671,2.539,2.5,5.382,2.5,8.539c0,3.224-0.776,5.947-2.329,8.184
|
||||
c-1.553,2.237-3.461,3.947-5.724,5.145v0.539c2.987,1.25,5.421,3.158,7.342,5.724c1.908,2.566,2.868,5.632,2.868,9.211
|
||||
s-0.908,6.776-2.724,9.579c-1.816,2.803-4.329,5.013-7.513,6.618c-3.197,1.605-6.789,2.421-10.776,2.421
|
||||
C73.408,129.263,69.145,127.934,65.211,125.276z"/>
|
||||
<path fill="#1A73E8" d="M121.25,79.961l-9.974,7.25l-5.013-7.605l17.987-12.974h6.895v61.197h-9.895L121.25,79.961z"/>
|
||||
<path fill="#EA4335" d="M148.882,196.25l47.368-47.368l-23.684-10.526l-23.684,10.526l-10.526,23.684L148.882,196.25z"/>
|
||||
<path fill="#34A853" d="M33.092,172.566l10.526,23.684h105.263v-47.368H43.618L33.092,172.566z"/>
|
||||
<path fill="#4285F4" d="M12.039-3.75C3.316-3.75-3.75,3.316-3.75,12.039v136.842l23.684,10.526l23.684-10.526V43.618h105.263
|
||||
l10.526-23.684L148.882-3.75H12.039z"/>
|
||||
<path fill="#188038" d="M-3.75,148.882v31.579c0,8.724,7.066,15.789,15.789,15.789h31.579v-47.368H-3.75z"/>
|
||||
<path fill="#FBBC04" d="M148.882,43.618v105.263h47.368V43.618l-23.684-10.526L148.882,43.618z"/>
|
||||
<path fill="#1967D2" d="M196.25,43.618V12.039c0-8.724-7.066-15.789-15.789-15.789h-31.579v47.368H196.25z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
1
packages/docs/pages/public/favicons/pipedrive.svg
Normal file
1
packages/docs/pages/public/favicons/pipedrive.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32" fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_503_588)" fill="#017737"><path d="M32 16C32 24.8366 24.8366 32 16 32C7.16344 32 0 24.8366 0 16C0 7.16344 7.16344 0 16 0C24.8366 0 32 7.16344 32 16Z" fill="#017737"></path><path d="M24.9842 13.4564C24.9842 17.8851 22.1247 20.914 18.036 20.914C16.0923 20.914 14.4903 20.1136 13.8906 19.1134L13.9189 20.142V26.4847H9.74512V10.0846C9.74512 9.85644 9.68836 9.79843 9.4304 9.79843H8V6.31321H11.4889C13.0896 6.31321 13.4907 7.68461 13.6042 8.28525C14.2337 7.22834 15.8911 6 18.2359 6C22.2679 5.99871 24.9842 8.99802 24.9842 13.4564ZM20.724 13.4847C20.724 11.1131 19.1801 9.48523 17.2351 9.48523C15.6344 9.48523 13.8325 10.5421 13.8325 13.5144C13.8325 15.4568 14.9186 17.4855 17.1783 17.4855C18.837 17.4842 20.724 16.2843 20.724 13.4847Z" fill="#FFFFFF"></path></g></svg>
|
After Width: | Height: | Size: 929 B |
Reference in New Issue
Block a user