Compare commits
111 Commits
new-or-upd
...
migrate-fl
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9752e2c4d2 | ||
![]() |
a5b31da3cc | ||
![]() |
8f7785e9d2 | ||
![]() |
69297c2dd8 | ||
![]() |
1c8e9fac7c | ||
![]() |
590780a539 | ||
![]() |
cbd1f47e87 | ||
![]() |
f89cff4e4a | ||
![]() |
cb08e0bf9f | ||
![]() |
3b54b29a99 | ||
![]() |
25983e046c | ||
![]() |
a6a124d2e6 | ||
![]() |
c7e1d30553 | ||
![]() |
6cc8c45634 | ||
![]() |
ee9a9114b7 | ||
![]() |
11f00f866c | ||
![]() |
03ea61ba81 | ||
![]() |
f6c500c998 | ||
![]() |
b590f0f98f | ||
![]() |
ef9359b208 | ||
![]() |
efd243a340 | ||
![]() |
bafb8b86db | ||
![]() |
84b701747f | ||
![]() |
ec42446daa | ||
![]() |
5046c4c911 | ||
![]() |
ce8c9906cb | ||
![]() |
6fb5482bba | ||
![]() |
58189963f5 | ||
![]() |
f488a71304 | ||
![]() |
4b706e004d | ||
![]() |
40e10cc270 | ||
![]() |
41db227eb3 | ||
![]() |
43eea965c5 | ||
![]() |
8101c9f0bc | ||
![]() |
b4cda90338 | ||
![]() |
7ca37c412e | ||
![]() |
e4e3356dc9 | ||
![]() |
0deaa03218 | ||
![]() |
a7104c41a2 | ||
![]() |
5176b8c322 | ||
![]() |
c37c70446d | ||
![]() |
63abc8a2c8 | ||
![]() |
ba5c038e3b | ||
![]() |
a6669415f5 | ||
![]() |
4086fad867 | ||
![]() |
8a71c13078 | ||
![]() |
5d77f64e76 | ||
![]() |
0d092b977f | ||
![]() |
69582ff83d | ||
![]() |
a5c7da331a | ||
![]() |
8e842296b7 | ||
![]() |
7db14d1df7 | ||
![]() |
067ec2eb9c | ||
![]() |
2d332b32d9 | ||
![]() |
1d9ad2ba86 | ||
![]() |
a28e2177f7 | ||
![]() |
18fe0df691 | ||
![]() |
8e21a06d99 | ||
![]() |
2daf5473bb | ||
![]() |
928ff53adf | ||
![]() |
a71e95e6e5 | ||
![]() |
cb4a54b5cc | ||
![]() |
37e4524156 | ||
![]() |
9ac24ee051 | ||
![]() |
f28ccd559a | ||
![]() |
8e84a93d8e | ||
![]() |
d871dec1b7 | ||
![]() |
b133e1a197 | ||
![]() |
9346a037b9 | ||
![]() |
89facbcddd | ||
![]() |
53fef35638 | ||
![]() |
bfe496a09b | ||
![]() |
ff774c2e8e | ||
![]() |
08a6d1078c | ||
![]() |
e9bcc919bf | ||
![]() |
04f4693c85 | ||
![]() |
2a58a0a4c4 | ||
![]() |
d911843648 | ||
![]() |
c80d178410 | ||
![]() |
9fb4dca39b | ||
![]() |
0dd444d50b | ||
![]() |
f3bf418997 | ||
![]() |
676027245f | ||
![]() |
6c5039f1ba | ||
![]() |
807be59f25 | ||
![]() |
8e9896ec2e | ||
![]() |
110c2dbac8 | ||
![]() |
f55ec4bd8a | ||
![]() |
06c9bf420e | ||
![]() |
3c9bc53a79 | ||
![]() |
de7a35dfe9 | ||
![]() |
92638c2e97 | ||
![]() |
63251e6a9a | ||
![]() |
59844c33fd | ||
![]() |
d36dd2ece1 | ||
![]() |
1fdb94739b | ||
![]() |
8a18f4c44f | ||
![]() |
c9c47c5519 | ||
![]() |
6be8b55daa | ||
![]() |
f2dc2f5530 | ||
![]() |
42842e7aec | ||
![]() |
49d9f77d1b | ||
![]() |
d06a89564f | ||
![]() |
58a8510d49 | ||
![]() |
8055d6555e | ||
![]() |
39620d3510 | ||
![]() |
6d19711926 | ||
![]() |
0b362dd435 | ||
![]() |
9485731e7d | ||
![]() |
1449fb0f84 | ||
![]() |
e548dd49ca |
@@ -33,7 +33,32 @@ services:
|
||||
- '6379:6379'
|
||||
expose:
|
||||
- 6379
|
||||
keycloak:
|
||||
image: quay.io/keycloak/keycloak:21.1
|
||||
restart: always
|
||||
container_name: keycloak
|
||||
environment:
|
||||
- KEYCLOAK_ADMIN=admin
|
||||
- KEYCLOAK_ADMIN_PASSWORD=admin
|
||||
- KC_DB=postgres
|
||||
- KC_DB_URL_HOST=postgres
|
||||
- KC_DB_URL_DATABASE=keycloak
|
||||
- KC_DB_USERNAME=automatisch_user
|
||||
- KC_DB_PASSWORD=automatisch_password
|
||||
- KC_HEALTH_ENABLED=true
|
||||
ports:
|
||||
- "8080:8080"
|
||||
command: start-dev
|
||||
depends_on:
|
||||
- postgres
|
||||
healthcheck:
|
||||
test: "curl -f http://localhost:8080/health/ready || exit 1"
|
||||
volumes:
|
||||
- keycloak:/opt/keycloak/data/
|
||||
expose:
|
||||
- 8080
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
keycloak:
|
||||
|
25
.github/workflows/playwright.yml
vendored
Normal file
25
.github/workflows/playwright.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
name: Automatisch UI Test
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 12 * * *'
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
- name: Install Playwright Browsers
|
||||
run: yarn playwright install --with-deps
|
||||
- name: Run Playwright tests
|
||||
run: yarn playwright test
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
retention-days: 30
|
@@ -4,7 +4,7 @@ WORKDIR /automatisch
|
||||
|
||||
RUN \
|
||||
apk --no-cache add --virtual build-dependencies python3 build-base && \
|
||||
yarn global add @automatisch/cli@0.7.1 --network-timeout 1000000 && \
|
||||
yarn global add @automatisch/cli@0.8.0 --network-timeout 1000000 && \
|
||||
rm -rf /usr/local/share/.cache/ && \
|
||||
apk del build-dependencies
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM automatischio/automatisch:0.7.1
|
||||
FROM automatischio/automatisch:0.8.0
|
||||
WORKDIR /automatisch
|
||||
|
||||
RUN apk add --no-cache openssl dos2unix
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.7.1",
|
||||
"version": "0.8.0",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"command": {
|
||||
|
@@ -2,18 +2,33 @@ import appConfig from '../../src/config/app';
|
||||
import logger from '../../src/helpers/logger';
|
||||
import client from './client';
|
||||
import User from '../../src/models/user';
|
||||
import Role from '../../src/models/role';
|
||||
import '../../src/config/orm';
|
||||
|
||||
async function fetchAdminRole() {
|
||||
const role = await Role
|
||||
.query()
|
||||
.where({
|
||||
key: 'admin'
|
||||
})
|
||||
.limit(1)
|
||||
.first();
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
export async function createUser(
|
||||
email = 'user@automatisch.io',
|
||||
password = 'sample'
|
||||
) {
|
||||
const UNIQUE_VIOLATION_CODE = '23505';
|
||||
|
||||
const role = await fetchAdminRole();
|
||||
const userParams = {
|
||||
email,
|
||||
password,
|
||||
fullName: 'Initial admin',
|
||||
role: 'admin',
|
||||
roleId: role.id,
|
||||
};
|
||||
|
||||
try {
|
||||
|
@@ -12,6 +12,7 @@ const knexConfig = {
|
||||
database: appConfig.postgresDatabase,
|
||||
ssl: appConfig.postgresEnableSsl,
|
||||
},
|
||||
asyncStackTraces: appConfig.isDev,
|
||||
searchPath: [appConfig.postgresSchema],
|
||||
pool: { min: 0, max: 20 },
|
||||
migrations: {
|
||||
|
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "@automatisch/backend",
|
||||
"version": "0.7.1",
|
||||
"version": "0.8.0",
|
||||
"license": "See LICENSE file",
|
||||
"description": "The open source Zapier alternative. Build workflow automation without spending time and money.",
|
||||
"scripts": {
|
||||
"dev": "ts-node-dev --exit-child src/server.ts",
|
||||
"dev": "ts-node-dev --watch 'src/graphql/schema.graphql' --exit-child src/server.ts",
|
||||
"worker": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/worker.ts",
|
||||
"build": "tsc && yarn copy-statics",
|
||||
"build:watch": "nodemon --watch 'src/**/*.ts' --watch 'bin/**/*.ts' --exec yarn build --ext ts",
|
||||
@@ -22,14 +22,18 @@
|
||||
"prebuild": "rm -rf ./dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@automatisch/web": "^0.7.1",
|
||||
"@automatisch/web": "^0.8.0",
|
||||
"@bull-board/express": "^3.10.1",
|
||||
"@casl/ability": "^6.5.0",
|
||||
"@graphql-tools/graphql-file-loader": "^7.3.4",
|
||||
"@graphql-tools/load": "^7.5.2",
|
||||
"@node-saml/passport-saml": "^4.0.4",
|
||||
"@rudderstack/rudder-sdk-node": "^1.1.2",
|
||||
"@sentry/node": "^7.42.0",
|
||||
"@sentry/tracing": "^7.42.0",
|
||||
"@types/luxon": "^2.3.1",
|
||||
"@types/passport": "^1.0.12",
|
||||
"@types/xmlrpc": "^1.3.7",
|
||||
"ajv-formats": "^2.1.1",
|
||||
"axios": "0.24.0",
|
||||
"bcrypt": "^5.0.1",
|
||||
@@ -49,6 +53,8 @@
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"handlebars": "^4.7.7",
|
||||
"http-errors": "~1.6.3",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.1",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"knex": "^2.4.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
@@ -56,13 +62,17 @@
|
||||
"memory-cache": "^0.2.0",
|
||||
"morgan": "^1.10.0",
|
||||
"multer": "1.4.5-lts.1",
|
||||
"node-html-markdown": "^1.3.0",
|
||||
"nodemailer": "6.7.0",
|
||||
"oauth-1.0a": "^2.2.6",
|
||||
"objection": "^3.0.0",
|
||||
"passport": "^0.6.0",
|
||||
"pg": "^8.7.1",
|
||||
"php-serialize": "^4.0.2",
|
||||
"showdown": "^2.1.0",
|
||||
"stripe": "^11.13.0",
|
||||
"winston": "^3.7.1"
|
||||
"winston": "^3.7.1",
|
||||
"xmlrpc": "^1.3.2"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
@@ -100,7 +110,7 @@
|
||||
"url": "https://github.com/automatisch/automatisch/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@automatisch/types": "^0.7.1",
|
||||
"@automatisch/types": "^0.8.0",
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/bull": "^3.15.8",
|
||||
"@types/cors": "^2.8.12",
|
||||
@@ -116,6 +126,7 @@
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@types/pg": "^8.6.1",
|
||||
"@types/pino": "^7.0.5",
|
||||
"@types/showdown": "^2.0.1",
|
||||
"ava": "^3.15.0",
|
||||
"nodemon": "^2.0.13",
|
||||
"sinon": "^11.1.2",
|
||||
|
@@ -17,6 +17,7 @@ import {
|
||||
} from './helpers/create-bull-board-handler';
|
||||
import injectBullBoardHandler from './helpers/inject-bull-board-handler';
|
||||
import router from './routes';
|
||||
import configurePassport from './helpers/passport';
|
||||
|
||||
createBullBoardHandler(serverAdapter);
|
||||
|
||||
@@ -50,6 +51,9 @@ app.use(
|
||||
})
|
||||
);
|
||||
app.use(cors(corsOptions));
|
||||
|
||||
configurePassport(app);
|
||||
|
||||
app.use('/', router);
|
||||
|
||||
webUIHandler(app);
|
||||
|
@@ -20,7 +20,7 @@ export default defineAction({
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: 'Language to translate the text to.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
value: '',
|
||||
options: [
|
||||
{ label: 'Bulgarian', value: 'BG' },
|
||||
|
@@ -13,7 +13,7 @@ export default defineAction({
|
||||
required: true,
|
||||
value: null,
|
||||
description: 'Delay for unit, e.g. minutes, hours, days, weeks.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Minutes',
|
||||
|
@@ -11,7 +11,7 @@ export default defineAction({
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: 'Pick a channel to send the message to.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
|
@@ -19,8 +19,8 @@ export default {
|
||||
|
||||
channels.data = response.data
|
||||
.filter((channel: IJSONObject) => {
|
||||
// filter in text channels only
|
||||
return channel.type === 0;
|
||||
// filter in text channels and announcement channels only
|
||||
return channel.type === 0 || channel.type === 5;
|
||||
})
|
||||
.map((channel: IJSONObject) => {
|
||||
return {
|
||||
|
3
packages/backend/src/apps/formatter/actions/index.ts
Normal file
3
packages/backend/src/apps/formatter/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import text from './text';
|
||||
|
||||
export default [text];
|
64
packages/backend/src/apps/formatter/actions/text/index.ts
Normal file
64
packages/backend/src/apps/formatter/actions/text/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import capitalize from './transformers/capitalize';
|
||||
import htmlToMarkdown from './transformers/html-to-markdown';
|
||||
import markdownToHtml from './transformers/markdown-to-html';
|
||||
import useDefaultValue from './transformers/use-default-value';
|
||||
import extractEmailAddress from './transformers/extract-email-address';
|
||||
|
||||
const transformers = {
|
||||
capitalize,
|
||||
htmlToMarkdown,
|
||||
markdownToHtml,
|
||||
useDefaultValue,
|
||||
extractEmailAddress,
|
||||
};
|
||||
|
||||
export default defineAction({
|
||||
name: 'Text',
|
||||
key: 'text',
|
||||
description:
|
||||
'Transform text data to capitalize, extract emails, apply default value, and much more.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Transform',
|
||||
key: 'transform',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: 'Pick a channel to send the message to.',
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Capitalize', value: 'capitalize' },
|
||||
{ label: 'Convert HTML to Markdown', value: 'htmlToMarkdown' },
|
||||
{ label: 'Convert Markdown to HTML', value: 'markdownToHtml' },
|
||||
{ label: 'Use Default Value', value: 'useDefaultValue' },
|
||||
{ label: 'Extract Email Address', value: 'extractEmailAddress' },
|
||||
],
|
||||
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,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
@@ -0,0 +1,11 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { capitalize as lodashCapitalize } from 'lodash';
|
||||
|
||||
const capitalize = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
const capitalizedInput = input.replace(/\w+/g, lodashCapitalize);
|
||||
|
||||
return capitalizedInput;
|
||||
};
|
||||
|
||||
export default capitalize;
|
@@ -0,0 +1,12 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const extractEmailAddress = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
const emailRegexp =
|
||||
/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
||||
|
||||
const email = input.match(emailRegexp);
|
||||
return email ? email[0] : '';
|
||||
};
|
||||
|
||||
export default extractEmailAddress;
|
@@ -0,0 +1,11 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { NodeHtmlMarkdown } from 'node-html-markdown';
|
||||
|
||||
const htmlToMarkdown = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
|
||||
const markdown = NodeHtmlMarkdown.translate(input);
|
||||
return markdown;
|
||||
};
|
||||
|
||||
export default htmlToMarkdown;
|
@@ -0,0 +1,13 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import showdown from 'showdown';
|
||||
|
||||
const converter = new showdown.Converter();
|
||||
|
||||
const markdownToHtml = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
|
||||
const html = converter.makeHtml(input);
|
||||
return html;
|
||||
};
|
||||
|
||||
export default markdownToHtml;
|
@@ -0,0 +1,13 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const useDefaultValue = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
|
||||
if (input && input.trim().length > 0) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return $.step.parameters.defaultValue as string;
|
||||
};
|
||||
|
||||
export default useDefaultValue;
|
3
packages/backend/src/apps/formatter/assets/favicon.svg
Normal file
3
packages/backend/src/apps/formatter/assets/favicon.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4 4H20M4 12H20M4 20H20M4 8H14M4 16H14" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 243 B |
@@ -0,0 +1,3 @@
|
||||
import listTransformOptions from './list-transform-options';
|
||||
|
||||
export default [listTransformOptions];
|
@@ -0,0 +1,23 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
import capitalize from './options/capitalize';
|
||||
import htmlToMarkdown from './options/html-to-markdown';
|
||||
import markdownToHtml from './options/markdown-to-html';
|
||||
import useDefaultValue from './options/use-default-value';
|
||||
import extractEmailAddress from './options/extract-email-address';
|
||||
|
||||
const options: IJSONObject = {
|
||||
capitalize,
|
||||
htmlToMarkdown,
|
||||
markdownToHtml,
|
||||
useDefaultValue,
|
||||
extractEmailAddress,
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'List fields after transform',
|
||||
key: 'listTransformOptions',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
return options[$.step.parameters.transform as string];
|
||||
},
|
||||
};
|
@@ -0,0 +1,12 @@
|
||||
const capitalize = [
|
||||
{
|
||||
label: 'Input',
|
||||
key: 'input',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Text that will be capitalized.',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default capitalize;
|
@@ -0,0 +1,12 @@
|
||||
const extractEmailAddress = [
|
||||
{
|
||||
label: 'Input',
|
||||
key: 'input',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Text that will be searched for an email address.',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default extractEmailAddress;
|
@@ -0,0 +1,12 @@
|
||||
const htmlToMarkdown = [
|
||||
{
|
||||
label: 'Input',
|
||||
key: 'input',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'HTML that will be converted to Markdown.',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default htmlToMarkdown;
|
@@ -0,0 +1,12 @@
|
||||
const markdownToHtml = [
|
||||
{
|
||||
label: 'Input',
|
||||
key: 'input',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Markdown text that will be converted to HTML.',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default markdownToHtml;
|
@@ -0,0 +1,21 @@
|
||||
const useDefaultValue = [
|
||||
{
|
||||
label: 'Input',
|
||||
key: 'input',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Text you want to check whether it is empty or not.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Default Value',
|
||||
key: 'defaultValue',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description:
|
||||
'Text that will be used as a default value if the input is empty.',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
|
||||
export default useDefaultValue;
|
0
packages/backend/src/apps/formatter/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/formatter/index.d.ts
vendored
Normal file
16
packages/backend/src/apps/formatter/index.ts
Normal file
16
packages/backend/src/apps/formatter/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import actions from './actions';
|
||||
import dynamicFields from './dynamic-fields';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Formatter',
|
||||
key: 'formatter',
|
||||
iconUrl: '{BASE_URL}/apps/formatter/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/formatter/connection',
|
||||
supportsConnections: false,
|
||||
baseUrl: '',
|
||||
apiBaseUrl: '',
|
||||
primaryColor: '001F52',
|
||||
actions,
|
||||
dynamicFields,
|
||||
});
|
@@ -11,7 +11,7 @@ export default defineAction({
|
||||
key: 'repo',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
|
@@ -6,7 +6,7 @@ import actions from './actions';
|
||||
import dynamicData from './dynamic-data';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Github',
|
||||
name: 'GitHub',
|
||||
key: 'github',
|
||||
baseUrl: 'https://github.com',
|
||||
apiBaseUrl: 'https://api.github.com',
|
||||
|
@@ -25,6 +25,12 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
$.auth.data.accessToken = data.access_token;
|
||||
|
||||
const currentUser = await getCurrentUser($);
|
||||
const screenName = [
|
||||
currentUser.username,
|
||||
$.auth.data.instanceUrl,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' @ ');
|
||||
|
||||
await $.auth.set({
|
||||
clientId: $.auth.data.clientId,
|
||||
@@ -34,7 +40,7 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
scope: data.scope,
|
||||
tokenType: data.token_type,
|
||||
userId: currentUser.id,
|
||||
screenName: `${currentUser.username} @ ${$.auth.data.instanceUrl}`,
|
||||
screenName,
|
||||
});
|
||||
};
|
||||
|
||||
|
@@ -9,11 +9,11 @@ export default {
|
||||
// ref:
|
||||
// - https://docs.gitlab.com/ee/api/projects.html#list-all-projects
|
||||
// - https://docs.gitlab.com/ee/api/rest/index.html#keyset-based-pagination
|
||||
|
||||
const firstPageRequest = $.http.get('/api/v4/projects', {
|
||||
params: {
|
||||
simple: true,
|
||||
pagination: 'keyset',
|
||||
membership: true,
|
||||
order_by: 'id',
|
||||
sort: 'asc',
|
||||
},
|
||||
|
@@ -6,7 +6,7 @@ import triggers from './triggers';
|
||||
import dynamicData from './dynamic-data';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Gitlab',
|
||||
name: 'GitLab',
|
||||
key: 'gitlab',
|
||||
baseUrl: 'https://gitlab.com',
|
||||
apiBaseUrl: 'https://gitlab.com',
|
||||
|
@@ -21,7 +21,7 @@ export default defineAction({
|
||||
required: false,
|
||||
description:
|
||||
'The Google Drive where your spreadsheet resides. If nothing is selected, then your personal Google Drive will be used.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
@@ -40,7 +40,7 @@ export default defineAction({
|
||||
required: true,
|
||||
dependsOn: ['parameters.driveId'],
|
||||
description: 'The spreadsheets in your Google Drive.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
@@ -63,7 +63,7 @@ export default defineAction({
|
||||
required: true,
|
||||
dependsOn: ['parameters.spreadsheetId'],
|
||||
description: 'The worksheets in your selected spreadsheet.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
|
@@ -0,0 +1,105 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
type THeaders = {
|
||||
__id: string;
|
||||
header: string;
|
||||
}[];
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create spreadsheet',
|
||||
key: 'createSpreadsheet',
|
||||
description:
|
||||
'Create a blank spreadsheet or duplicate an existing spreadsheet. Optionally, provide headers.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Spreadsheet to copy',
|
||||
key: 'spreadsheetId',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
description: 'Choose a spreadsheet to copy its data.',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listSpreadsheets',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Headers',
|
||||
key: 'headers',
|
||||
type: 'dynamic' as const,
|
||||
required: false,
|
||||
description:
|
||||
'These headers are ignored if "Spreadsheet to Copy" is selected.',
|
||||
fields: [
|
||||
{
|
||||
label: 'Header',
|
||||
key: 'header',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
if ($.step.parameters.spreadsheetId) {
|
||||
const body = { name: $.step.parameters.title };
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`https://www.googleapis.com/drive/v3/files/${$.step.parameters.spreadsheetId}/copy`,
|
||||
body
|
||||
);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
} else {
|
||||
const headers = $.step.parameters.headers as THeaders;
|
||||
const values = headers.map((entry) => entry.header);
|
||||
|
||||
const spreadsheetBody = {
|
||||
properties: {
|
||||
title: $.step.parameters.title,
|
||||
},
|
||||
sheets: [
|
||||
{
|
||||
data: [
|
||||
{
|
||||
startRow: 0,
|
||||
startColumn: 0,
|
||||
rowData: [
|
||||
{
|
||||
values: values.map((header) => ({
|
||||
userEnteredValue: { stringValue: header },
|
||||
})),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const { data } = await $.http.post('/v4/spreadsheets', spreadsheetBody);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
@@ -0,0 +1,191 @@
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
type THeaders = {
|
||||
__id: string;
|
||||
header: string;
|
||||
}[];
|
||||
|
||||
type TSheetsResponse = {
|
||||
sheets: {
|
||||
properties: {
|
||||
sheetId: string;
|
||||
title: string;
|
||||
};
|
||||
}[];
|
||||
};
|
||||
|
||||
type TBody = {
|
||||
requests: IJSONObject[];
|
||||
};
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create worksheet',
|
||||
key: 'createWorksheet',
|
||||
description:
|
||||
'Create a blank worksheet with a title. Optionally, provide headers.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Drive',
|
||||
key: 'driveId',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
description:
|
||||
'The Google Drive where your spreadsheet resides. If nothing is selected, then your personal Google Drive will be used.',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listDrives',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Spreadsheet',
|
||||
key: 'spreadsheetId',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
dependsOn: ['parameters.driveId'],
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listSpreadsheets',
|
||||
},
|
||||
{
|
||||
name: 'parameters.driveId',
|
||||
value: '{parameters.driveId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Headers',
|
||||
key: 'headers',
|
||||
type: 'dynamic' as const,
|
||||
required: false,
|
||||
fields: [
|
||||
{
|
||||
label: 'Header',
|
||||
key: 'header',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Overwrite',
|
||||
key: 'overwrite',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
value: false,
|
||||
description:
|
||||
'If a worksheet with the specified title exists, its content would be lost. Please, use with caution.',
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Yes',
|
||||
value: 'true',
|
||||
},
|
||||
{
|
||||
label: 'No',
|
||||
value: 'false',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
data: { sheets },
|
||||
} = await $.http.get<TSheetsResponse>(
|
||||
`/v4/spreadsheets/${$.step.parameters.spreadsheetId}`
|
||||
);
|
||||
const selectedSheet = sheets.find(
|
||||
(sheet) => sheet.properties.title === $.step.parameters.title
|
||||
);
|
||||
const headers = $.step.parameters.headers as THeaders;
|
||||
const values = headers.map((entry) => entry.header);
|
||||
|
||||
const body: TBody = {
|
||||
requests: [
|
||||
{
|
||||
addSheet: {
|
||||
properties: {
|
||||
title: $.step.parameters.title,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
if ($.step.parameters.overwrite === 'true' && selectedSheet) {
|
||||
body.requests.unshift({
|
||||
deleteSheet: {
|
||||
sheetId: selectedSheet.properties.sheetId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`https://sheets.googleapis.com/v4/spreadsheets/${$.step.parameters.spreadsheetId}:batchUpdate`,
|
||||
body
|
||||
);
|
||||
|
||||
if (values.length) {
|
||||
const body = {
|
||||
requests: [
|
||||
{
|
||||
updateCells: {
|
||||
rows: [
|
||||
{
|
||||
values: values.map((header) => ({
|
||||
userEnteredValue: { stringValue: header },
|
||||
})),
|
||||
},
|
||||
],
|
||||
fields: '*',
|
||||
start: {
|
||||
sheetId:
|
||||
data.replies[data.replies.length - 1].addSheet.properties
|
||||
.sheetId,
|
||||
rowIndex: 0,
|
||||
columnIndex: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const { data: response } = await $.http.post(
|
||||
`https://sheets.googleapis.com/v4/spreadsheets/${$.step.parameters.spreadsheetId}:batchUpdate`,
|
||||
body
|
||||
);
|
||||
|
||||
$.setActionItem({
|
||||
raw: response,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,3 +1,5 @@
|
||||
import createSpreadsheet from './create-spreadsheet';
|
||||
import createSpreadsheetRow from './create-spreadsheet-row';
|
||||
import createWorksheet from './create-worksheet';
|
||||
|
||||
export default [createSpreadsheetRow];
|
||||
export default [createSpreadsheet, createSpreadsheetRow, createWorksheet];
|
||||
|
@@ -84,7 +84,7 @@ export default defineAction({
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Header key',
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
@@ -132,7 +132,7 @@ export default defineAction({
|
||||
|
||||
throwIfFileSizeExceedsLimit(metadataResponse.headers['content-length']);
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch {}
|
||||
} catch { }
|
||||
|
||||
const requestData: AxiosRequestConfig = {
|
||||
url,
|
||||
|
3
packages/backend/src/apps/mattermost/actions/index.ts
Normal file
3
packages/backend/src/apps/mattermost/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import sendMessageToChannel from './send-a-message-to-channel';
|
||||
|
||||
export default [sendMessageToChannel];
|
@@ -0,0 +1,42 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import postMessage from './post-message';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send a message to channel',
|
||||
key: 'sendMessageToChannel',
|
||||
description: 'Sends a message to a channel you specify.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Channel',
|
||||
key: 'channel',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: 'Pick a channel to send the message to.',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listChannels',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Message text',
|
||||
key: 'message',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'The content of your new message.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const message = await postMessage($);
|
||||
|
||||
return message;
|
||||
},
|
||||
});
|
@@ -0,0 +1,27 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
type TData = {
|
||||
channel_id: string;
|
||||
message: string;
|
||||
};
|
||||
|
||||
const postMessage = async ($: IGlobalVariable) => {
|
||||
const { parameters } = $.step;
|
||||
const channel_id = parameters.channel as string;
|
||||
const message = parameters.message as string;
|
||||
|
||||
const data: TData = {
|
||||
channel_id,
|
||||
message,
|
||||
};
|
||||
|
||||
const response = await $.http.post('/api/v4/posts', data);
|
||||
|
||||
const actionData = {
|
||||
raw: response?.data,
|
||||
};
|
||||
|
||||
$.setActionItem(actionData);
|
||||
};
|
||||
|
||||
export default postMessage;
|
6
packages/backend/src/apps/mattermost/assets/favicon.svg
Normal file
6
packages/backend/src/apps/mattermost/assets/favicon.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="256px" height="256px" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||
<g>
|
||||
<path d="M6.79123171,86.9648684 C25.2351716,32.4823178 76.783459,-1.43234143 131.421839,0.0464773399 L131.421839,0.0464773399 L113.909757,20.739032 C81.4957329,26.5997669 53.5072568,48.7337413 42.5072761,81.2287969 C26.140539,129.576353 53.572705,182.545803 103.779303,199.543648 C153.985902,216.538377 207.952658,191.12264 224.319395,142.7782 C235.283535,110.390667 226.589826,75.9306053 204.563374,51.5978814 L204.563374,51.5978814 L203.21701,24.4290666 C247.371203,56.4768925 267.622761,114.633895 249.208429,169.029181 C226.546194,235.970273 153.909545,271.865521 86.9684532,249.204844 C20.0273609,226.542609 -15.8694453,153.905961 6.79123171,86.9648684 Z M165.185344,11.9237762 C165.839826,11.6401671 166.594039,11.5793938 167.321762,11.8256038 C168.035459,12.0671391 168.585536,12.5580009 168.936152,13.1595015 L168.936152,13.1595015 L169.007833,13.2763734 L169.071723,13.4103864 C169.240019,13.7313945 169.383381,14.0991514 169.450388,14.5510559 C169.582343,15.4417519 169.641535,17.5358595 169.665634,19.6808502 L169.671365,20.2662434 C169.677102,20.9486534 169.679633,21.6256073 169.680171,22.2599793 L169.680173,22.7924325 C169.678741,24.5267431 169.663874,25.8268542 169.663874,25.8268542 L169.663874,25.8268542 L170.167202,44.7600977 L170.910507,66.6151379 L171.837691,104.59538 C171.837691,104.59538 171.83785,104.602367 171.838064,104.616156 L171.838772,104.677745 C171.838883,104.691349 171.838983,104.706608 171.839058,104.723498 L171.839105,104.844231 C171.832023,107.013302 171.387173,122.892918 160.122454,133.928662 C148.009853,145.795053 133.131285,144.708923 123.451177,141.433394 C113.771069,138.154749 101.293828,129.979951 98.8800345,113.195592 C96.8283098,98.9302108 104.41287,86.9390787 106.734401,83.6627102 L106.889339,83.4459953 C107.205256,83.0081712 107.389865,82.7777388 107.389865,82.7777388 L107.389865,82.7777388 L131.197445,53.1717559 L145.064682,36.2627333 L156.965355,21.5275276 C156.965355,21.5275276 158.715313,19.1834331 160.51647,16.874806 L160.876881,16.4142586 C161.477025,15.6498178 162.070275,14.9069442 162.593713,14.2737698 L162.898895,13.907734 C163.342593,13.3805415 163.71955,12.9564826 163.983901,12.6998055 C164.292443,12.4006135 164.608776,12.205827 164.918876,12.0546727 L164.918876,12.0546727 L165.146386,11.9393591 Z" fill="#0058CC"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,18 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { URL, URLSearchParams } from 'url';
|
||||
import getBaseUrl from '../common/get-base-url';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId as string,
|
||||
redirect_uri: $.auth.data.oAuthRedirectUrl as string,
|
||||
response_type: 'code',
|
||||
});
|
||||
|
||||
const baseUrl = getBaseUrl($);
|
||||
const path = `/oauth/authorize?${searchParams.toString()}`;
|
||||
|
||||
await $.auth.set({
|
||||
url: new URL(path, baseUrl).toString(),
|
||||
});
|
||||
}
|
57
packages/backend/src/apps/mattermost/auth/index.ts
Normal file
57
packages/backend/src/apps/mattermost/auth/index.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
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/mattermost/connections/add',
|
||||
placeholder: null,
|
||||
description:
|
||||
'When asked to input an OAuth callback or redirect URL in Mattermost OAuth, enter the URL above.',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'instanceUrl',
|
||||
label: 'Mattermost instance URL',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'Your Mattermost instance URL',
|
||||
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,
|
||||
};
|
@@ -0,0 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
const user = await getCurrentUser($);
|
||||
return !!user.id;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -0,0 +1,44 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const params = {
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri: redirectUri,
|
||||
};
|
||||
const headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded', // This is not documented yet required
|
||||
};
|
||||
const response = await $.http.post('/oauth/access_token', null, {
|
||||
params,
|
||||
headers,
|
||||
});
|
||||
|
||||
const {
|
||||
data: { access_token, refresh_token, scope, token_type },
|
||||
} = response;
|
||||
|
||||
$.auth.data.accessToken = response.data.access_token;
|
||||
|
||||
const currentUser = await getCurrentUser($);
|
||||
|
||||
await $.auth.set({
|
||||
clientId: $.auth.data.clientId,
|
||||
clientSecret: $.auth.data.clientSecret,
|
||||
accessToken: access_token,
|
||||
refreshToken: refresh_token,
|
||||
scope: scope,
|
||||
tokenType: token_type,
|
||||
userId: currentUser.id,
|
||||
screenName: currentUser.username,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -0,0 +1,12 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data?.accessToken) {
|
||||
requestConfig.headers = requestConfig.headers || {};
|
||||
requestConfig.headers.Authorization = `Bearer ${$.auth.data.accessToken}`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -0,0 +1,11 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addXRequestedWithHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
// This is not documented yet required
|
||||
// ref. https://forum.mattermost.com/t/solved-invalid-or-expired-session-please-login-again/6772
|
||||
requestConfig.headers = requestConfig.headers || {};
|
||||
requestConfig.headers['X-Requested-With'] = `XMLHttpRequest`;
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addXRequestedWithHeader;
|
@@ -0,0 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const getBaseUrl = ($: IGlobalVariable): string => {
|
||||
return $.auth.data.instanceUrl as string;
|
||||
};
|
||||
|
||||
export default getBaseUrl;
|
@@ -0,0 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const response = await $.http.get('/api/v4/users/me');
|
||||
const currentUser = response.data;
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
@@ -0,0 +1,9 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const setBaseUrl: TBeforeRequest = ($, requestConfig) => {
|
||||
requestConfig.baseURL = $.auth.data.instanceUrl as string;
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default setBaseUrl;
|
@@ -0,0 +1,3 @@
|
||||
import listChannels from './list-channels';
|
||||
|
||||
export default [listChannels];
|
@@ -0,0 +1,36 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
type TChannel = {
|
||||
id: string;
|
||||
display_name: string;
|
||||
};
|
||||
|
||||
type TResponse = {
|
||||
data: TChannel[];
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'List channels',
|
||||
key: 'listChannels',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const channels: {
|
||||
data: IJSONObject[];
|
||||
error: IJSONObject | null;
|
||||
} = {
|
||||
data: [],
|
||||
error: null,
|
||||
};
|
||||
|
||||
const response: TResponse = await $.http.get('/api/v4/users/me/channels'); // this endpoint will return only channels user joined, there is no endpoint to list all channels available for user
|
||||
|
||||
for (const channel of response.data) {
|
||||
channels.data.push({
|
||||
value: channel.id as string,
|
||||
name: (channel.display_name as string) || (channel.id as string), // it's possible for channel to not have any name thus falling back to using id
|
||||
});
|
||||
}
|
||||
|
||||
return channels;
|
||||
},
|
||||
};
|
0
packages/backend/src/apps/mattermost/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/mattermost/index.d.ts
vendored
Normal file
22
packages/backend/src/apps/mattermost/index.ts
Normal file
22
packages/backend/src/apps/mattermost/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import addXRequestedWithHeader from './common/add-x-requested-with-header';
|
||||
import setBaseUrl from './common/set-base-url';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import dynamicData from './dynamic-data';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Mattermost',
|
||||
key: 'mattermost',
|
||||
iconUrl: '{BASE_URL}/apps/mattermost/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/mattermost/connection',
|
||||
baseUrl: 'https://mattermost.com',
|
||||
apiBaseUrl: '', // there is no cloud version of this app, user always need to provide address of own instance when creating connection
|
||||
primaryColor: '4a154b',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [setBaseUrl, addXRequestedWithHeader, addAuthHeader],
|
||||
auth,
|
||||
actions,
|
||||
dynamicData,
|
||||
});
|
@@ -0,0 +1,100 @@
|
||||
import { IJSONArray, IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
type TBody = {
|
||||
parent: IJSONObject;
|
||||
properties: IJSONObject;
|
||||
children: IJSONArray;
|
||||
};
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create database item',
|
||||
key: 'createDatabaseItem',
|
||||
description: 'Creates an item in a database.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Database',
|
||||
key: 'databaseId',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listDatabases',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description:
|
||||
'This field has a 2000 character limit. Any characters beyond 2000 will not be included.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Content',
|
||||
key: 'content',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description:
|
||||
'The text to add to the page body. The max length for this field is 2000 characters. Any characters beyond 2000 will not be included.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const name = $.step.parameters.name as string;
|
||||
const truncatedName = name.slice(0, 2000);
|
||||
const content = $.step.parameters.content as string;
|
||||
const truncatedContent = content.slice(0, 2000);
|
||||
|
||||
const body: TBody = {
|
||||
parent: {
|
||||
database_id: $.step.parameters.databaseId,
|
||||
},
|
||||
properties: {},
|
||||
children: [],
|
||||
};
|
||||
|
||||
if (name) {
|
||||
body.properties.Name = {
|
||||
title: [
|
||||
{
|
||||
text: {
|
||||
content: truncatedName,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (content) {
|
||||
body.children = [
|
||||
{
|
||||
object: 'block',
|
||||
paragraph: {
|
||||
rich_text: [
|
||||
{
|
||||
text: {
|
||||
content: truncatedContent,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const { data } = await $.http.post('/v1/pages', body);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
104
packages/backend/src/apps/notion/actions/create-page/index.ts
Normal file
104
packages/backend/src/apps/notion/actions/create-page/index.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { IJSONArray, IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
type TBody = {
|
||||
parent: IJSONObject;
|
||||
properties: IJSONObject;
|
||||
children: IJSONArray;
|
||||
};
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create page',
|
||||
key: 'createPage',
|
||||
description: 'Creates a page inside a parent page',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Parent page',
|
||||
key: 'parentPageId',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listParentPages',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description:
|
||||
'This field has a 2000 character limit. Any characters beyond 2000 will not be included.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Content',
|
||||
key: 'content',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description:
|
||||
'The text to add to the page body. The max length for this field is 2000 characters. Any characters beyond 2000 will not be included.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const parentPageId = $.step.parameters.parentPageId as string;
|
||||
const title = $.step.parameters.title as string;
|
||||
const truncatedTitle = title.slice(0, 2000);
|
||||
const content = $.step.parameters.content as string;
|
||||
const truncatedContent = content.slice(0, 2000);
|
||||
|
||||
const body: TBody = {
|
||||
parent: {
|
||||
page_id: parentPageId,
|
||||
},
|
||||
properties: {},
|
||||
children: [],
|
||||
};
|
||||
|
||||
if (title) {
|
||||
body.properties.title = {
|
||||
type: 'title',
|
||||
title: [
|
||||
{
|
||||
text: {
|
||||
content: truncatedTitle,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (content) {
|
||||
body.children = [
|
||||
{
|
||||
object: 'block',
|
||||
type: 'paragraph',
|
||||
paragraph: {
|
||||
rich_text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: truncatedContent,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const { data } = await $.http.post('/v1/pages', body);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
@@ -0,0 +1,70 @@
|
||||
import { IJSONArray, IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
type TBody = {
|
||||
filter: IJSONObject;
|
||||
sorts: IJSONArray;
|
||||
};
|
||||
|
||||
export default defineAction({
|
||||
name: 'Find database item',
|
||||
key: 'findDatabaseItem',
|
||||
description: 'Searches for an item in a database by property.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Database',
|
||||
key: 'databaseId',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listDatabases',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description:
|
||||
'This field has a 2000 character limit. Any characters beyond 2000 will not be included.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const databaseId = $.step.parameters.databaseId as string;
|
||||
const name = $.step.parameters.name as string;
|
||||
const truncatedName = name.slice(0, 2000);
|
||||
|
||||
const body: TBody = {
|
||||
filter: {
|
||||
property: 'Name',
|
||||
rich_text: {
|
||||
equals: truncatedName,
|
||||
},
|
||||
},
|
||||
sorts: [
|
||||
{
|
||||
timestamp: 'last_edited_time',
|
||||
direction: 'descending',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`/v1/databases/${databaseId}/query`,
|
||||
body
|
||||
);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data.results[0],
|
||||
});
|
||||
},
|
||||
});
|
5
packages/backend/src/apps/notion/actions/index.ts
Normal file
5
packages/backend/src/apps/notion/actions/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import createDatabaseItem from './create-database-item';
|
||||
import createPage from './create-page';
|
||||
import findDatabaseItem from './find-database-item';
|
||||
|
||||
export default [createDatabaseItem, createPage, findDatabaseItem];
|
7
packages/backend/src/apps/notion/assets/favicon.svg
Normal file
7
packages/backend/src/apps/notion/assets/favicon.svg
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="256px" height="268px" viewBox="0 0 256 268" version="1.1" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid">
|
||||
<g>
|
||||
<path d="M16.0924984,11.5384656 L164.089991,0.608048392 C182.268719,-0.952166138 186.940447,0.0998642306 198.370133,8.40912104 L245.613429,41.6907258 C253.405586,47.4144843 256,48.9746988 256,55.2066414 L256,237.73391 C256,249.172512 251.845372,255.939385 237.304172,256.973584 L65.4398551,267.377986 C54.5272689,267.895086 49.3295257,266.334872 43.6146827,259.050899 L8.82635648,213.813593 C2.58549836,205.486505 0,199.254562 0,191.970589 L0,29.7261093 C0,20.3737376 4.1546284,12.572665 16.0924984,11.5384656 Z" fill="#FFFFFF"></path>
|
||||
<path d="M164.089991,0.608048392 L16.0924984,11.5384656 C4.1546284,12.572665 0,20.3737376 0,29.7261093 L0,191.970589 C0,199.254562 2.58549836,205.486505 8.82635648,213.813593 L43.6146827,259.050899 C49.3295257,266.334872 54.5272689,267.895086 65.4398551,267.377986 L237.304172,256.973584 C251.836456,255.939385 256,249.172512 256,237.73391 L256,55.2066414 C256,49.2956572 253.664136,47.5927945 246.790277,42.5466149 C246.394749,42.2616979 245.999494,41.9764014 245.604513,41.6907258 L198.370133,8.40912104 C186.940447,0.0998642306 182.268719,-0.952166138 164.089991,0.608048392 Z M69.3270182,52.219945 C55.2940029,53.1649893 52.1111653,53.3789615 44.1406979,46.8973846 L23.8757401,30.7781396 C21.8162569,28.6919099 22.8504562,26.0885805 28.039284,25.5714809 L170.313018,15.1759943 C182.259804,14.1328795 188.482831,18.2964234 193.154559,21.9339521 L217.556314,39.6134116 C218.599429,40.1394268 221.193843,43.2509404 218.073414,43.2509404 L71.1457825,52.0951279 L69.3270182,52.219945 Z M52.9670544,236.173696 L52.9670544,81.2221043 C52.9670544,74.455231 55.0443686,71.3348019 61.2673957,70.8087867 L230.020199,60.9303999 C235.743958,60.4133002 238.329456,64.0508289 238.329456,70.8087867 L238.329456,224.726179 C238.329456,231.493052 237.286341,237.216811 227.942885,237.73391 L66.4562234,247.095198 C57.1127673,247.612297 52.9670544,244.500784 52.9670544,236.173696 Z M212.376402,89.5313611 C213.410601,94.2120046 212.376402,98.8926482 207.695758,99.4275789 L199.912517,100.969962 L199.912517,215.373807 C193.154559,219.011336 186.931532,221.08865 181.733788,221.08865 C173.424532,221.08865 171.347217,218.485321 165.12419,210.693164 L114.225535,130.614039 L114.225535,208.089834 L130.326949,211.736279 C130.326949,211.736279 130.326949,221.097566 117.337048,221.097566 L81.523438,223.17488 C80.4803232,221.08865 81.523438,215.890907 85.1520513,214.856708 L94.5044229,212.262294 L94.5044229,109.823065 L81.523438,108.771035 C80.4803232,104.090391 83.0747371,97.3324337 90.3497945,96.8064185 L128.77565,94.2209202 L181.733788,175.334245 L181.733788,103.573292 L168.235704,102.021993 C167.192589,96.2893189 171.347217,92.1257749 176.536045,91.6175908 L212.376402,89.5313611 L212.376402,89.5313611 Z" fill="#000000"></path>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.9 KiB |
21
packages/backend/src/apps/notion/auth/generate-auth-url.ts
Normal file
21
packages/backend/src/apps/notion/auth/generate-auth-url.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URL, 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,
|
||||
response_type: 'code',
|
||||
owner: 'user',
|
||||
});
|
||||
|
||||
const url = new URL(`/v1/oauth/authorize?${searchParams}`, $.app.apiBaseUrl).toString();
|
||||
|
||||
await $.auth.set({
|
||||
url,
|
||||
});
|
||||
}
|
49
packages/backend/src/apps/notion/auth/index.ts
Normal file
49
packages/backend/src/apps/notion/auth/index.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
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/notion/connections/add',
|
||||
placeholder: null,
|
||||
description:
|
||||
'When asked to input an OAuth callback or redirect URL in Notion OAuth, enter the URL above.',
|
||||
docUrl: 'https://automatisch.io/docs/notion#oauth-redirect-url',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
docUrl: 'https://automatisch.io/docs/notion#client-id',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: null,
|
||||
docUrl: 'https://automatisch.io/docs/notion#client-secret',
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
generateAuthUrl,
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
};
|
@@ -0,0 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
const user = await getCurrentUser($);
|
||||
return !!user.id;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
53
packages/backend/src/apps/notion/auth/verify-credentials.ts
Normal file
53
packages/backend/src/apps/notion/auth/verify-credentials.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { IGlobalVariable, IField } from '@automatisch/types';
|
||||
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 response = await $.http.post(
|
||||
`${$.app.apiBaseUrl}/v1/oauth/token`,
|
||||
{
|
||||
redirect_uri: redirectUri,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Basic ${Buffer.from(
|
||||
$.auth.data.clientId + ':' + $.auth.data.clientSecret
|
||||
).toString('base64')}`,
|
||||
},
|
||||
additionalProperties: {
|
||||
skipAddingAuthHeader: true
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const data = response.data;
|
||||
|
||||
$.auth.data.accessToken = data.access_token;
|
||||
|
||||
await $.auth.set({
|
||||
clientId: $.auth.data.clientId,
|
||||
clientSecret: $.auth.data.clientSecret,
|
||||
accessToken: data.access_token,
|
||||
botId: data.bot_id,
|
||||
duplicatedTemplateId: data.duplicated_template_id,
|
||||
owner: data.owner,
|
||||
tokenType: data.token_type,
|
||||
workspaceIcon: data.workspace_icon,
|
||||
workspaceId: data.workspace_id,
|
||||
workspaceName: data.workspace_name,
|
||||
screenName: data.workspace_name,
|
||||
});
|
||||
|
||||
const currentUser = await getCurrentUser($);
|
||||
|
||||
await $.auth.set({
|
||||
screenName: `${currentUser.name} @ ${data.workspace_name}`,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
14
packages/backend/src/apps/notion/common/add-auth-header.ts
Normal file
14
packages/backend/src/apps/notion/common/add-auth-header.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if (requestConfig.additionalProperties?.skipAddingAuthHeader) return requestConfig;
|
||||
|
||||
if ($.auth.data?.accessToken) {
|
||||
const authorizationHeader = `Bearer ${$.auth.data.accessToken}`;
|
||||
requestConfig.headers.Authorization = authorizationHeader;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -0,0 +1,9 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addNotionVersionHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
requestConfig.headers['Notion-Version'] = '2022-06-28';
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addNotionVersionHeader;
|
17
packages/backend/src/apps/notion/common/get-current-user.ts
Normal file
17
packages/backend/src/apps/notion/common/get-current-user.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
type Owner = {
|
||||
user: {
|
||||
id: string
|
||||
}
|
||||
}
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const userId = ($.auth.data.owner as Owner).user.id;
|
||||
const response = await $.http.get(`/v1/users/${userId}`);
|
||||
|
||||
const currentUser = response.data;
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
4
packages/backend/src/apps/notion/dynamic-data/index.ts
Normal file
4
packages/backend/src/apps/notion/dynamic-data/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import listDatabases from './list-databases';
|
||||
import listParentPages from './list-parent-pages';
|
||||
|
||||
export default [listDatabases, listParentPages];
|
@@ -0,0 +1,60 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
type Database = {
|
||||
id: string;
|
||||
name: string;
|
||||
title: [
|
||||
{
|
||||
plain_text: string;
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
type ResponseData = {
|
||||
results: Database[];
|
||||
next_cursor?: string;
|
||||
}
|
||||
|
||||
type Payload = {
|
||||
filter: {
|
||||
value: 'database';
|
||||
property: 'object';
|
||||
};
|
||||
start_cursor?: string;
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'List databases',
|
||||
key: 'listDatabases',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const databases: {
|
||||
data: IJSONObject[];
|
||||
error: IJSONObject | null;
|
||||
} = {
|
||||
data: [],
|
||||
error: null,
|
||||
};
|
||||
const payload: Payload = {
|
||||
filter: {
|
||||
value: 'database',
|
||||
property: 'object'
|
||||
},
|
||||
};
|
||||
|
||||
do {
|
||||
const response = await $.http.post<ResponseData>('/v1/search', payload);
|
||||
|
||||
payload.start_cursor = response.data.next_cursor;
|
||||
|
||||
for (const database of response.data.results) {
|
||||
databases.data.push({
|
||||
value: database.id as string,
|
||||
name: database.title[0].plain_text as string,
|
||||
});
|
||||
}
|
||||
} while (payload.start_cursor);
|
||||
|
||||
return databases;
|
||||
},
|
||||
};
|
@@ -0,0 +1,70 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
type Page = {
|
||||
id: string;
|
||||
properties: {
|
||||
title: {
|
||||
title: [
|
||||
{
|
||||
plain_text: string;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
parent: {
|
||||
workspace: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
type ResponseData = {
|
||||
results: Page[];
|
||||
next_cursor?: string;
|
||||
};
|
||||
|
||||
type Payload = {
|
||||
filter: {
|
||||
value: 'page';
|
||||
property: 'object';
|
||||
};
|
||||
start_cursor?: string;
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'List parent pages',
|
||||
key: 'listParentPages',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const parentPages: {
|
||||
data: IJSONObject[];
|
||||
error: IJSONObject | null;
|
||||
} = {
|
||||
data: [],
|
||||
error: null,
|
||||
};
|
||||
const payload: Payload = {
|
||||
filter: {
|
||||
value: 'page',
|
||||
property: 'object',
|
||||
},
|
||||
};
|
||||
|
||||
do {
|
||||
const response = await $.http.post<ResponseData>('/v1/search', payload);
|
||||
|
||||
payload.start_cursor = response.data.next_cursor;
|
||||
|
||||
const topLevelPages = response.data.results.filter(
|
||||
(page) => page.parent.workspace
|
||||
);
|
||||
|
||||
for (const pages of topLevelPages) {
|
||||
parentPages.data.push({
|
||||
value: pages.id as string,
|
||||
name: pages.properties.title.title[0].plain_text as string,
|
||||
});
|
||||
}
|
||||
} while (payload.start_cursor);
|
||||
|
||||
return parentPages;
|
||||
},
|
||||
};
|
0
packages/backend/src/apps/notion/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/notion/index.d.ts
vendored
Normal file
23
packages/backend/src/apps/notion/index.ts
Normal file
23
packages/backend/src/apps/notion/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import addNotionVersionHeader from './common/add-notion-version-header';
|
||||
import auth from './auth';
|
||||
import triggers from './triggers';
|
||||
import actions from './actions';
|
||||
import dynamicData from './dynamic-data';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Notion',
|
||||
key: 'notion',
|
||||
baseUrl: 'https://notion.com',
|
||||
apiBaseUrl: 'https://api.notion.com',
|
||||
iconUrl: '{BASE_URL}/apps/notion/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/notion/connection',
|
||||
primaryColor: '000000',
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader, addNotionVersionHeader],
|
||||
auth,
|
||||
triggers,
|
||||
actions,
|
||||
dynamicData,
|
||||
});
|
3
packages/backend/src/apps/notion/triggers/index.ts
Normal file
3
packages/backend/src/apps/notion/triggers/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import newDatabaseItems from './new-database-items';
|
||||
|
||||
export default [newDatabaseItems];
|
@@ -0,0 +1,32 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import newDatabaseItems from './new-database-items';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New database items',
|
||||
key: 'newDatabaseItems',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new database item is created',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Database',
|
||||
key: 'databaseId',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
variables: false,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listDatabases',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
await newDatabaseItems($);
|
||||
},
|
||||
});
|
@@ -0,0 +1,50 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
type DatabaseItem = {
|
||||
id: string;
|
||||
}
|
||||
|
||||
type ResponseData = {
|
||||
results: DatabaseItem[];
|
||||
next_cursor?: string;
|
||||
}
|
||||
|
||||
type Payload = {
|
||||
sorts: [
|
||||
{
|
||||
timestamp: 'created_time' | 'last_edited_time';
|
||||
direction: 'ascending' | 'descending';
|
||||
}
|
||||
];
|
||||
start_cursor?: string;
|
||||
};
|
||||
|
||||
const newDatabaseItems = async ($: IGlobalVariable) => {
|
||||
const payload: Payload = {
|
||||
sorts: [
|
||||
{
|
||||
timestamp: 'created_time',
|
||||
direction: 'descending'
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
const databaseId = $.step.parameters.databaseId as string;
|
||||
const path = `/v1/databases/${databaseId}/query`;
|
||||
do {
|
||||
const response = await $.http.post<ResponseData>(path, payload);
|
||||
|
||||
payload.start_cursor = response.data.next_cursor;
|
||||
|
||||
for (const databaseItem of response.data.results) {
|
||||
$.pushTriggerItem({
|
||||
raw: databaseItem,
|
||||
meta: {
|
||||
internalId: databaseItem.id,
|
||||
}
|
||||
})
|
||||
}
|
||||
} while (payload.start_cursor);
|
||||
};
|
||||
|
||||
export default newDatabaseItems;
|
103
packages/backend/src/apps/odoo/actions/create-lead/index.ts
Normal file
103
packages/backend/src/apps/odoo/actions/create-lead/index.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { authenticate, asyncMethodCall } from '../../common/xmlrpc-client';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create Lead',
|
||||
key: 'createLead',
|
||||
description: '',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Lead name',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Type',
|
||||
key: 'type',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Lead',
|
||||
value: 'lead'
|
||||
},
|
||||
{
|
||||
label: 'Opportunity',
|
||||
value: 'opportunity'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Email",
|
||||
key: 'email',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Email of lead contact',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: "Contact Name",
|
||||
key: 'contactName',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Name of lead contact',
|
||||
variables: true
|
||||
},
|
||||
{
|
||||
label: 'Phone Number',
|
||||
key: 'phoneNumber',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Phone number of lead contact',
|
||||
variables: true
|
||||
},
|
||||
{
|
||||
label: 'Mobile Number',
|
||||
key: 'mobileNumber',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Mobile number of lead contact',
|
||||
variables: true
|
||||
}
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const uid = await authenticate($);
|
||||
const id = await asyncMethodCall(
|
||||
$,
|
||||
{
|
||||
method: 'execute_kw',
|
||||
params: [
|
||||
$.auth.data.databaseName,
|
||||
uid,
|
||||
$.auth.data.apiKey,
|
||||
'crm.lead',
|
||||
'create',
|
||||
[
|
||||
{
|
||||
name: $.step.parameters.name,
|
||||
type: $.step.parameters.type,
|
||||
email_from: $.step.parameters.email,
|
||||
contact_name: $.step.parameters.contactName,
|
||||
phone: $.step.parameters.phoneNumber,
|
||||
mobile: $.step.parameters.mobileNumber
|
||||
}
|
||||
]
|
||||
],
|
||||
path: 'object',
|
||||
},
|
||||
);
|
||||
|
||||
$.setActionItem(
|
||||
{
|
||||
raw: {
|
||||
id: id
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
});
|
3
packages/backend/src/apps/odoo/actions/index.ts
Normal file
3
packages/backend/src/apps/odoo/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import createLead from './create-lead';
|
||||
|
||||
export default [createLead];
|
1
packages/backend/src/apps/odoo/assets/favicon.svg
Normal file
1
packages/backend/src/apps/odoo/assets/favicon.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="191"><circle cx="527.5" cy="118.4" r="72.4" fill="#888"/><path d="M527.5 161.1c23.6 0 42.7-19.1 42.7-42.7s-19.1-42.7-42.7-42.7-42.7 19.1-42.7 42.7 19.1 42.7 42.7 42.7z" fill="#fff"/><circle cx="374" cy="118.4" r="72.4" fill="#888"/><path d="M374 161.1c23.6 0 42.7-19.1 42.7-42.7S397.6 75.7 374 75.7s-42.7 19.1-42.7 42.7 19.1 42.7 42.7 42.7z" fill="#fff"/><path d="M294.9 117.8v.6c0 40-32.4 72.4-72.4 72.4s-72.4-32.4-72.4-72.4S182.5 46 222.5 46c16.4 0 31.5 5.5 43.7 14.6V14.4A14.34 14.34 0 0 1 280.6 0c7.9 0 14.4 6.5 14.4 14.4v102.7c0 .2 0 .5-.1.7z" fill="#888"/><circle cx="222.5" cy="118.4" r="42.7" fill="#fff"/><circle cx="72.4" cy="118.2" r="72.4" fill="#9c5789"/><circle cx="71.7" cy="118.5" r="42.7" fill="#fff"/><script xmlns=""/></svg>
|
After Width: | Height: | Size: 803 B |
65
packages/backend/src/apps/odoo/auth/index.ts
Normal file
65
packages/backend/src/apps/odoo/auth/index.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'host',
|
||||
label: 'Host Name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'Host name of your Odoo Server',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'port',
|
||||
label: 'Port',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: '443',
|
||||
placeholder: null,
|
||||
description: 'Port that the host is running on, defaults to 443 (HTTPS)',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'databaseName',
|
||||
label: 'Database Name',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'Name of your Odoo database',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'email',
|
||||
label: 'Email Address',
|
||||
type: 'string' as const,
|
||||
requires: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'Email Address of the account that will be interacting with the database',
|
||||
clickToCopy: false
|
||||
},
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'API Key for your Odoo account',
|
||||
clickToCopy: false
|
||||
}
|
||||
],
|
||||
|
||||
verifyCredentials,
|
||||
isStillVerified
|
||||
};
|
9
packages/backend/src/apps/odoo/auth/is-still-verified.ts
Normal file
9
packages/backend/src/apps/odoo/auth/is-still-verified.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import {IGlobalVariable} from '@automatisch/types';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
}
|
||||
|
||||
export default isStillVerified;
|
16
packages/backend/src/apps/odoo/auth/verify-credentials.ts
Normal file
16
packages/backend/src/apps/odoo/auth/verify-credentials.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { authenticate } from '../common/xmlrpc-client';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
try {
|
||||
await authenticate($);
|
||||
|
||||
await $.auth.set({
|
||||
screenName: `${$.auth.data.email} @ ${$.auth.data.databaseName} - ${$.auth.data.host}`,
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error('Failed while authorizing!');
|
||||
}
|
||||
}
|
||||
|
||||
export default verifyCredentials;
|
67
packages/backend/src/apps/odoo/common/xmlrpc-client.ts
Normal file
67
packages/backend/src/apps/odoo/common/xmlrpc-client.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { join } from 'node:path';
|
||||
import xmlrpc from 'xmlrpc';
|
||||
import { IGlobalVariable } from "@automatisch/types";
|
||||
|
||||
type AsyncMethodCallPayload = {
|
||||
method: string;
|
||||
params: any[];
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export const asyncMethodCall = async <T = number>($: IGlobalVariable, { method, params, path }: AsyncMethodCallPayload): Promise<T> => {
|
||||
return new Promise(
|
||||
(resolve, reject) => {
|
||||
const client = getClient($, { path });
|
||||
|
||||
client.methodCall(
|
||||
method,
|
||||
params,
|
||||
(error, response) => {
|
||||
if (error != null) {
|
||||
// something went wrong on the server side, display the error returned by Odoo
|
||||
reject(error);
|
||||
}
|
||||
|
||||
resolve(response);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const getClient = ($: IGlobalVariable, { path = 'common' }) => {
|
||||
const host = $.auth.data.host as string;
|
||||
const port = Number($.auth.data.port as string);
|
||||
|
||||
return xmlrpc.createClient(
|
||||
{
|
||||
host,
|
||||
port,
|
||||
path: join('/xmlrpc/2', path),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const authenticate = async ($: IGlobalVariable) => {
|
||||
const uid = await asyncMethodCall(
|
||||
$,
|
||||
{
|
||||
method: 'authenticate',
|
||||
params: [
|
||||
$.auth.data.databaseName,
|
||||
$.auth.data.email,
|
||||
$.auth.data.apiKey,
|
||||
[]
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
if (!Number.isInteger(uid)) {
|
||||
// failed to authenticate
|
||||
throw new Error(
|
||||
'Failed to connect to the Odoo server. Please, check the credentials!'
|
||||
);
|
||||
}
|
||||
|
||||
return uid;
|
||||
}
|
0
packages/backend/src/apps/odoo/index.d.ts
vendored
Normal file
0
packages/backend/src/apps/odoo/index.d.ts
vendored
Normal file
16
packages/backend/src/apps/odoo/index.ts
Normal file
16
packages/backend/src/apps/odoo/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Odoo',
|
||||
key: 'odoo',
|
||||
iconUrl: '{BASE_URL}/apps/odoo/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/odoo/connection',
|
||||
supportsConnections: true,
|
||||
baseUrl: 'https://odoo.com',
|
||||
apiBaseUrl: '',
|
||||
primaryColor: '9c5789',
|
||||
auth,
|
||||
actions
|
||||
});
|
@@ -19,7 +19,7 @@ export default defineAction({
|
||||
key: 'model',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
@@ -35,7 +35,7 @@ export default defineAction({
|
||||
label: 'Messages',
|
||||
key: 'messages',
|
||||
type: 'dynamic' as const,
|
||||
required: false,
|
||||
required: true,
|
||||
description: 'Add or remove messages as needed',
|
||||
value: [{ role: 'system', body: '' }],
|
||||
fields: [
|
||||
|
@@ -14,7 +14,7 @@ export default defineAction({
|
||||
key: 'model',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
|
@@ -18,14 +18,14 @@ export default defineAction({
|
||||
type: 'string' as const,
|
||||
value: 'public',
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Table name',
|
||||
key: 'table',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Where clause entries',
|
||||
@@ -38,14 +38,14 @@ export default defineAction({
|
||||
key: 'columnName',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Operator',
|
||||
key: 'operator',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: whereClauseOperators
|
||||
},
|
||||
{
|
||||
@@ -69,7 +69,7 @@ export default defineAction({
|
||||
key: 'parameter',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
@@ -102,6 +102,8 @@ export default defineAction({
|
||||
})
|
||||
.del() as IJSONArray;
|
||||
|
||||
client.destroy();
|
||||
|
||||
$.setActionItem({
|
||||
raw: {
|
||||
rows: response
|
||||
|
@@ -16,14 +16,14 @@ export default defineAction({
|
||||
type: 'string' as const,
|
||||
value: 'public',
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Table name',
|
||||
key: 'table',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Column - value entries',
|
||||
@@ -37,7 +37,7 @@ export default defineAction({
|
||||
key: 'columnName',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
@@ -52,7 +52,7 @@ export default defineAction({
|
||||
label: 'Run-time parameters',
|
||||
key: 'params',
|
||||
type: 'dynamic' as const,
|
||||
required: false,
|
||||
required: true,
|
||||
description: 'Change run-time configuration parameters with SET command',
|
||||
fields: [
|
||||
{
|
||||
@@ -60,7 +60,7 @@ export default defineAction({
|
||||
key: 'parameter',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
@@ -88,6 +88,8 @@ export default defineAction({
|
||||
.returning('*')
|
||||
.insert(data) as IJSONObject;
|
||||
|
||||
client.destroy();
|
||||
|
||||
$.setActionItem({ raw: response[0] as IJSONObject });
|
||||
},
|
||||
});
|
||||
|
@@ -27,7 +27,7 @@ export default defineAction({
|
||||
key: 'parameter',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
@@ -46,6 +46,7 @@ export default defineAction({
|
||||
|
||||
const queryStatemnt = $.step.parameters.queryStatement;
|
||||
const { rows } = await client.raw(queryStatemnt);
|
||||
client.destroy();
|
||||
|
||||
$.setActionItem({
|
||||
raw: {
|
||||
|
@@ -19,14 +19,14 @@ export default defineAction({
|
||||
type: 'string' as const,
|
||||
value: 'public',
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Table name',
|
||||
key: 'table',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Where clause entries',
|
||||
@@ -39,14 +39,14 @@ export default defineAction({
|
||||
key: 'columnName',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Operator',
|
||||
key: 'operator',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: whereClauseOperators
|
||||
},
|
||||
{
|
||||
@@ -70,7 +70,7 @@ export default defineAction({
|
||||
key: 'columnName',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
@@ -93,7 +93,7 @@ export default defineAction({
|
||||
key: 'parameter',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Value',
|
||||
@@ -132,6 +132,8 @@ export default defineAction({
|
||||
})
|
||||
.update(data) as IJSONArray;
|
||||
|
||||
client.destroy();
|
||||
|
||||
$.setActionItem({
|
||||
raw: {
|
||||
rows: response
|
||||
|
@@ -5,6 +5,7 @@ import getClient from '../common/postgres-client';
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const client = getClient($);
|
||||
const checkConnection = await client.raw('SELECT 1');
|
||||
client.destroy();
|
||||
|
||||
logger.debug(checkConnection);
|
||||
|
||||
|
@@ -10,6 +10,7 @@ export default defineAction({
|
||||
key: 'object',
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'Pick which type of object you want to search for.',
|
||||
source: {
|
||||
type: 'query',
|
||||
@@ -28,7 +29,7 @@ export default defineAction({
|
||||
type: 'dropdown' as const,
|
||||
description: 'Pick which field to search by',
|
||||
required: true,
|
||||
variables: false,
|
||||
variables: true,
|
||||
dependsOn: ['parameters.object'],
|
||||
source: {
|
||||
type: 'query',
|
||||
|
@@ -23,7 +23,7 @@ export default defineAction({
|
||||
'Sort messages by their match strength or by their date. Default is score.',
|
||||
required: true,
|
||||
value: 'score',
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Match strength',
|
||||
@@ -43,7 +43,7 @@ export default defineAction({
|
||||
'Sort matching messages in ascending or descending order. Default is descending.',
|
||||
required: true,
|
||||
value: 'desc',
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Descending (newest or best match first)',
|
||||
|
@@ -12,7 +12,7 @@ export default defineAction({
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: 'Pick a user to send the message to.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
@@ -40,7 +40,7 @@ export default defineAction({
|
||||
value: false,
|
||||
description:
|
||||
'If you choose no, this message will appear to come from you. Direct messages are always sent by bots.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Yes',
|
||||
|
@@ -12,7 +12,7 @@ export default defineAction({
|
||||
type: 'dropdown' as const,
|
||||
required: true,
|
||||
description: 'Pick a channel to send the message to.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
@@ -40,7 +40,7 @@ export default defineAction({
|
||||
value: false,
|
||||
description:
|
||||
'If you choose no, this message will appear to come from you. Direct messages are always sent by bots.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Yes',
|
||||
|
@@ -29,7 +29,7 @@ export default defineAction({
|
||||
required: false,
|
||||
value: false,
|
||||
description: 'Sends the message silently. Users will receive a notification with no sound.',
|
||||
variables: false,
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'Yes',
|
||||
|
@@ -10,7 +10,7 @@ export default defineAction({
|
||||
key: 'projectId',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
@@ -27,7 +27,7 @@ export default defineAction({
|
||||
key: 'sectionId',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
variables: false,
|
||||
variables: true,
|
||||
dependsOn: ['parameters.projectId'],
|
||||
source: {
|
||||
type: 'query',
|
||||
|
@@ -13,7 +13,7 @@ export default defineAction({
|
||||
required: true,
|
||||
description:
|
||||
'The number to send the SMS from. Include country code. Example: 15551234567',
|
||||
variables: false,
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user