Compare commits
210 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
51e96b832d | ||
![]() |
60b20c4d01 | ||
![]() |
8b4aee1afa | ||
![]() |
51abd74304 | ||
![]() |
b93b465f09 | ||
![]() |
5aad68ec62 | ||
![]() |
74fbc937a1 | ||
![]() |
7e35f544eb | ||
![]() |
ed1c3cffc1 | ||
![]() |
c4983a9f9b | ||
![]() |
5b43262e7a | ||
![]() |
dad4408679 | ||
![]() |
a78c4d12b4 | ||
![]() |
74664a9df8 | ||
![]() |
fce5281a03 | ||
![]() |
de0bd2f486 | ||
![]() |
079fb5d108 | ||
![]() |
1c7435a32b | ||
![]() |
1afd374cf6 | ||
![]() |
3adf549915 | ||
![]() |
e94d669eca | ||
![]() |
5fac0b4689 | ||
![]() |
832d323a6e | ||
![]() |
03f1dbd5b2 | ||
![]() |
c0a216f109 | ||
![]() |
ad67b13270 | ||
![]() |
5d420c08c6 | ||
![]() |
3d8235c670 | ||
![]() |
5a209f81d1 | ||
![]() |
d17d8e2805 | ||
![]() |
ca7636e7bc | ||
![]() |
532cfc10d0 | ||
![]() |
72d68c4377 | ||
![]() |
00f5964aa4 | ||
![]() |
fcf345abab | ||
![]() |
24ad43d3e4 | ||
![]() |
9a7cdf42e1 | ||
![]() |
c36b652d5b | ||
![]() |
553070fc23 | ||
![]() |
5d69f7e24f | ||
![]() |
bc0e2bada0 | ||
![]() |
80b6cc1d94 | ||
![]() |
bce3273e64 | ||
![]() |
3abf61152a | ||
![]() |
14923d4cd6 | ||
![]() |
6fdc4bf900 | ||
![]() |
d21e1f75b5 | ||
![]() |
84a0b37fcc | ||
![]() |
f135a0f09e | ||
![]() |
0f24c99456 | ||
![]() |
9eae0ab947 | ||
![]() |
3bf1f79c79 | ||
![]() |
b21074c871 | ||
![]() |
d7893d9a32 | ||
![]() |
9cbdda330c | ||
![]() |
42a9bfd099 | ||
![]() |
eb15bd01ca | ||
![]() |
9e98aebeb3 | ||
![]() |
1361cbc826 | ||
![]() |
679d0808a9 | ||
![]() |
6fe9a548ad | ||
![]() |
2d6d2430d2 | ||
![]() |
a445538e81 | ||
![]() |
50d38ffbd8 | ||
![]() |
93bcdfd9c9 | ||
![]() |
5be3b101a5 | ||
![]() |
024c7476c7 | ||
![]() |
30a7ffe93d | ||
![]() |
e2d803ebf7 | ||
![]() |
be7e67c940 | ||
![]() |
ead4b13ba5 | ||
![]() |
e02c42ee18 | ||
![]() |
d39886fdf8 | ||
![]() |
11a425f1de | ||
![]() |
f0e194e584 | ||
![]() |
d4b9331cf2 | ||
![]() |
37e1acc5f1 | ||
![]() |
ffaf6a577d | ||
![]() |
afdaf6ba39 | ||
![]() |
4c49367910 | ||
![]() |
a506c4411d | ||
![]() |
1859c9854e | ||
![]() |
6ff29b9ae6 | ||
![]() |
3578f6b849 | ||
![]() |
0347864fde | ||
![]() |
5f9786a2c7 | ||
![]() |
75aeff1898 | ||
![]() |
0afcdce6d3 | ||
![]() |
a591d0ea87 | ||
![]() |
0e111a3532 | ||
![]() |
b599466ffa | ||
![]() |
69727e78df | ||
![]() |
02ae67b147 | ||
![]() |
a769f78801 | ||
![]() |
d583e42428 | ||
![]() |
da732becb6 | ||
![]() |
b89a4d58d9 | ||
![]() |
09854147d1 | ||
![]() |
3648c2bfe3 | ||
![]() |
3f3ee032f6 | ||
![]() |
68e5d54331 | ||
![]() |
824c434b0b | ||
![]() |
9f0e0ca656 | ||
![]() |
95f89ba03e | ||
![]() |
697f72ecf4 | ||
![]() |
4f03f2ab51 | ||
![]() |
c81531cb7a | ||
![]() |
7b6e4aa153 | ||
![]() |
f21039d19d | ||
![]() |
8c936a91be | ||
![]() |
24451892ff | ||
![]() |
6bba2c82fe | ||
![]() |
3320dc6bc4 | ||
![]() |
9d42fd9293 | ||
![]() |
e6b806616f | ||
![]() |
6ec5872391 | ||
![]() |
a26cf932a1 | ||
![]() |
38a3e3ab9f | ||
![]() |
32b17c1418 | ||
![]() |
44aa6a1579 | ||
![]() |
2369aacd2a | ||
![]() |
7dafc6364b | ||
![]() |
3d25fa0aeb | ||
![]() |
0297b0f296 | ||
![]() |
4c7d09c3d8 | ||
![]() |
48a74826e8 | ||
![]() |
ef34068ac4 | ||
![]() |
3987a8db77 | ||
![]() |
953c5a5b5b | ||
![]() |
4313265c00 | ||
![]() |
9405f267ba | ||
![]() |
1d29238199 | ||
![]() |
c5bf66f462 | ||
![]() |
e6180bdfaa | ||
![]() |
55c391afc8 | ||
![]() |
782fa67320 | ||
![]() |
1e3ab75bb7 | ||
![]() |
5f6dd12a73 | ||
![]() |
d18c06d2c4 | ||
![]() |
baf99a9cfe | ||
![]() |
159931a6ea | ||
![]() |
7831f2925b | ||
![]() |
8fcb7840de | ||
![]() |
9ece9461dc | ||
![]() |
b304acaaba | ||
![]() |
5a1960609a | ||
![]() |
476aa6e3aa | ||
![]() |
aa76007fd0 | ||
![]() |
17a8813c4b | ||
![]() |
fe79fc9003 | ||
![]() |
ac8649ac18 | ||
![]() |
817db026b1 | ||
![]() |
01ef97949b | ||
![]() |
9e151051a8 | ||
![]() |
0feab23eb6 | ||
![]() |
8957f83939 | ||
![]() |
3bf2bc94f3 | ||
![]() |
8c3d5f1f4b | ||
![]() |
124e6e0811 | ||
![]() |
54d9d17d14 | ||
![]() |
62bdb7fb6d | ||
![]() |
af6574fdf1 | ||
![]() |
115a993cd2 | ||
![]() |
188b6c2fe5 | ||
![]() |
99adb2ceda | ||
![]() |
6344a3bcef | ||
![]() |
f62c17de0b | ||
![]() |
9d269b8111 | ||
![]() |
49b26a9640 | ||
![]() |
dddb79eeb2 | ||
![]() |
b0909ecb98 | ||
![]() |
ec63ce0532 | ||
![]() |
1eb03e3afb | ||
![]() |
26d906f1b7 | ||
![]() |
af9ceac0b4 | ||
![]() |
911159a14f | ||
![]() |
6a639e4ac9 | ||
![]() |
c4a6c86a69 | ||
![]() |
d2bac9d8d1 | ||
![]() |
758aa50550 | ||
![]() |
1af887cee7 | ||
![]() |
34b115c694 | ||
![]() |
8e4935409f | ||
![]() |
ca32d221c4 | ||
![]() |
e2de1fe038 | ||
![]() |
80179062db | ||
![]() |
7143620d25 | ||
![]() |
a0e51e2a7e | ||
![]() |
53dbd01cb1 | ||
![]() |
3607c16fd1 | ||
![]() |
4dfdd01295 | ||
![]() |
8983a3c581 | ||
![]() |
9cddef9108 | ||
![]() |
3dbea953a7 | ||
![]() |
962bbc04b5 | ||
![]() |
0804026d74 | ||
![]() |
879aa1f9f8 | ||
![]() |
9ffe2c14df | ||
![]() |
f0d2f07193 | ||
![]() |
ccf5928262 | ||
![]() |
b2f8634008 | ||
![]() |
43dba351c3 | ||
![]() |
b95478b635 | ||
![]() |
523f8a8951 | ||
![]() |
0f71924d06 | ||
![]() |
6d1bfc0be0 | ||
![]() |
b0f53268f6 | ||
![]() |
75f5db23df | ||
![]() |
85141812d9 | ||
![]() |
8819ddefa7 |
@@ -8,7 +8,7 @@
|
||||
"version": "latest"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": 16
|
||||
"version": 18
|
||||
},
|
||||
"ghcr.io/devcontainers/features/common-utils:1": {
|
||||
"username": "vscode",
|
||||
|
51
.github/workflows/ci.yml
vendored
51
.github/workflows/ci.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
node-version: '18'
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
- run: yarn --frozen-lockfile
|
||||
- run: yarn lint
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
build-backend:
|
||||
start-backend-server:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
|
||||
@@ -33,13 +33,36 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
node-version: '18'
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- run: yarn --frozen-lockfile && yarn lerna bootstrap
|
||||
- run: cd packages/backend && yarn build
|
||||
- run: cd packages/backend && yarn start
|
||||
env:
|
||||
ENCRYPTION_KEY: sample_encryption_key
|
||||
WEBHOOK_SECRET_KEY: sample_webhook_secret_key
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
start-backend-worker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
|
||||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- run: yarn --frozen-lockfile && yarn lerna bootstrap
|
||||
- run: cd packages/backend && yarn start:worker
|
||||
env:
|
||||
ENCRYPTION_KEY: sample_encryption_key
|
||||
WEBHOOK_SECRET_KEY: sample_webhook_secret_key
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
build-web:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -50,7 +73,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
node-version: '18'
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||
@@ -60,21 +83,3 @@ jobs:
|
||||
env:
|
||||
CI: false
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
build-cli:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
|
||||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
cache: 'yarn'
|
||||
cache-dependency-path: yarn.lock
|
||||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- run: yarn --frozen-lockfile && yarn lerna bootstrap
|
||||
- run: cd packages/backend && yarn build
|
||||
- run: cd packages/cli && yarn build
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
|
6
.github/workflows/playwright.yml
vendored
6
.github/workflows/playwright.yml
vendored
@@ -63,13 +63,13 @@ jobs:
|
||||
- name: Install Playwright Browsers
|
||||
run: yarn playwright install --with-deps
|
||||
- name: Build Automatisch
|
||||
run: yarn lerna run --scope=@*/{web,backend,cli} build
|
||||
run: yarn lerna run --scope=@*/{web,cli} build
|
||||
env:
|
||||
# Keep this until we clean up warnings in build processes
|
||||
CI: false
|
||||
- name: Migrate database
|
||||
working-directory: ./packages/backend
|
||||
run: yarn db:migrate --migrations-directory ./dist/src/db/migrations
|
||||
run: yarn db:migrate
|
||||
- name: Seed user
|
||||
working-directory: ./packages/backend
|
||||
run: yarn db:seed:user &
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
run: yarn start &
|
||||
working-directory: ./packages/backend
|
||||
- name: Run Automatisch worker
|
||||
run: node dist/src/worker.js &
|
||||
run: yarn start:worker &
|
||||
working-directory: ./packages/backend
|
||||
- name: Setup upterm session
|
||||
if: false
|
||||
|
@@ -1 +1 @@
|
||||
16.15.0
|
||||
18.19.0
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM node:16-alpine
|
||||
FROM node:18-alpine
|
||||
WORKDIR /automatisch
|
||||
|
||||
RUN \
|
||||
|
@@ -1,17 +1,22 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM node:16-alpine
|
||||
WORKDIR /automatisch
|
||||
FROM node:18-alpine
|
||||
|
||||
ENV PORT 3000
|
||||
|
||||
RUN ls -lna
|
||||
RUN \
|
||||
apk --no-cache add --virtual build-dependencies python3 build-base git
|
||||
|
||||
# copy the app, note .dockerignore
|
||||
COPY . ./
|
||||
RUN git clone https://github.com/automatisch/automatisch.git
|
||||
|
||||
RUN yarn
|
||||
RUN yarn lerna bootstrap
|
||||
RUN yarn lerna run --scope=@*/{web,backend,cli} build
|
||||
WORKDIR /automatisch
|
||||
|
||||
RUN yarn install
|
||||
|
||||
RUN if [ "$WORKER" != "true" ]; then cd packages/web && yarn build; fi
|
||||
|
||||
RUN \
|
||||
rm -rf /usr/local/share/.cache/ && \
|
||||
apk del build-dependencies
|
||||
|
||||
COPY ./docker/entrypoint-cloud.sh /entrypoint-cloud.sh
|
||||
|
||||
|
@@ -2,8 +2,12 @@
|
||||
|
||||
set -e
|
||||
|
||||
cd packages/backend
|
||||
|
||||
if [ -n "$WORKER" ]; then
|
||||
yarn automatisch start-worker
|
||||
yarn start:worker
|
||||
else
|
||||
yarn automatisch start
|
||||
yarn db:migrate
|
||||
yarn db:seed:user
|
||||
yarn start
|
||||
fi
|
||||
|
@@ -6,8 +6,7 @@
|
||||
"start": "lerna run --stream --parallel --scope=@*/{web,backend} dev",
|
||||
"start:web": "lerna run --stream --scope=@*/web dev",
|
||||
"start:backend": "lerna run --stream --scope=@*/backend dev",
|
||||
"lint": "lerna run --no-bail --stream --parallel --scope=@*/{web,backend,cli} lint",
|
||||
"build:watch": "lerna run --no-bail --stream --parallel --scope=@*/{web,backend,cli} build:watch",
|
||||
"lint": "lerna run --no-bail --stream --parallel --scope=@*/{web,backend} lint",
|
||||
"build:docs": "cd ./packages/docs && yarn install && yarn build"
|
||||
},
|
||||
"workspaces": {
|
||||
@@ -18,7 +17,6 @@
|
||||
"**/babel-loader",
|
||||
"**/webpack",
|
||||
"**/@automatisch/web",
|
||||
"**/@automatisch/types",
|
||||
"**/ajv"
|
||||
]
|
||||
},
|
||||
|
@@ -1,28 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['@typescript-eslint'],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.test.ts', '**/test/**/*.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/ban-ts-comment': ['off'],
|
||||
'@typescript-eslint/no-explicit-any': ['off'],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': ['off'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
12
packages/backend/.eslintrc.json
Normal file
12
packages/backend/.eslintrc.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": ["eslint:recommended", "prettier"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
import { Client } from 'pg';
|
||||
import pg from 'pg';
|
||||
|
||||
const client = new Client({
|
||||
const client = new pg.Client({
|
||||
host: 'localhost',
|
||||
user: 'postgres',
|
||||
port: 5432,
|
31
packages/backend/bin/database/convert-migrations.js
Normal file
31
packages/backend/bin/database/convert-migrations.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import appConfig from '../../src/config/app.js';
|
||||
import logger from '../../src/helpers/logger.js';
|
||||
import '../../src/config/orm.js';
|
||||
import { client as knex } from '../../src/config/database.js';
|
||||
|
||||
export const renameMigrationsAsJsFiles = async () => {
|
||||
if (!appConfig.isDev) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const tableExists = await knex.schema.hasTable('knex_migrations');
|
||||
|
||||
if (tableExists) {
|
||||
await knex('knex_migrations')
|
||||
.where('name', 'like', '%.ts')
|
||||
.update({
|
||||
name: knex.raw("REPLACE(name, '.ts', '.js')"),
|
||||
});
|
||||
logger.info(
|
||||
`Migration file names with typescript renamed as JS file names!`
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(err.message);
|
||||
}
|
||||
|
||||
await knex.destroy();
|
||||
};
|
||||
|
||||
renameMigrationsAsJsFiles();
|
3
packages/backend/bin/database/create.js
Normal file
3
packages/backend/bin/database/create.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { createDatabaseAndUser } from './utils.js';
|
||||
|
||||
createDatabaseAndUser();
|
@@ -1,3 +0,0 @@
|
||||
import { createDatabaseAndUser } from './utils';
|
||||
|
||||
createDatabaseAndUser();
|
3
packages/backend/bin/database/drop.js
Normal file
3
packages/backend/bin/database/drop.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { dropDatabase } from './utils.js';
|
||||
|
||||
dropDatabase();
|
@@ -1,3 +0,0 @@
|
||||
import { dropDatabase } from './utils';
|
||||
|
||||
dropDatabase();
|
3
packages/backend/bin/database/seed-user.js
Normal file
3
packages/backend/bin/database/seed-user.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { createUser } from './utils.js';
|
||||
|
||||
createUser();
|
@@ -1,3 +0,0 @@
|
||||
import { createUser } from './utils';
|
||||
|
||||
createUser();
|
@@ -1,15 +1,15 @@
|
||||
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';
|
||||
import appConfig from '../../src/config/app.js';
|
||||
import logger from '../../src/helpers/logger.js';
|
||||
import client from './client.js';
|
||||
import User from '../../src/models/user.js';
|
||||
import Role from '../../src/models/role.js';
|
||||
import '../../src/config/orm.js';
|
||||
import process from 'process';
|
||||
|
||||
async function fetchAdminRole() {
|
||||
const role = await Role
|
||||
.query()
|
||||
const role = await Role.query()
|
||||
.where({
|
||||
key: 'admin'
|
||||
key: 'admin',
|
||||
})
|
||||
.limit(1)
|
||||
.first();
|
||||
@@ -41,12 +41,14 @@ export async function createUser(
|
||||
logger.info('No need to seed a user.');
|
||||
}
|
||||
} catch (err) {
|
||||
if ((err as any).nativeError.code !== UNIQUE_VIOLATION_CODE) {
|
||||
if (err.nativeError.code !== UNIQUE_VIOLATION_CODE) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
logger.info(`User already exists: ${email}`);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
export const createDatabaseAndUser = async (
|
||||
@@ -59,6 +61,7 @@ export const createDatabaseAndUser = async (
|
||||
await grantPrivileges(database, user);
|
||||
|
||||
await client.end();
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
export const createDatabase = async (database = appConfig.postgresDatabase) => {
|
||||
@@ -68,7 +71,7 @@ export const createDatabase = async (database = appConfig.postgresDatabase) => {
|
||||
await client.query(`CREATE DATABASE ${database}`);
|
||||
logger.info(`Database: ${database} created!`);
|
||||
} catch (err) {
|
||||
if ((err as any).code !== DUPLICATE_DB_CODE) {
|
||||
if (err.code !== DUPLICATE_DB_CODE) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -85,7 +88,7 @@ export const createDatabaseUser = async (user = appConfig.postgresUsername) => {
|
||||
|
||||
return result;
|
||||
} catch (err) {
|
||||
if ((err as any).code !== DUPLICATE_OBJECT_CODE) {
|
||||
if (err.code !== DUPLICATE_OBJECT_CODE) {
|
||||
throw err;
|
||||
}
|
||||
|
1
packages/backend/database-utils.d.ts
vendored
1
packages/backend/database-utils.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export * from './dist/bin/database/utils';
|
@@ -1,2 +0,0 @@
|
||||
/* eslint-disable */
|
||||
module.exports = require('./dist/bin/database/utils');
|
1
packages/backend/database.d.ts
vendored
1
packages/backend/database.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export * from './dist/src/config/database';
|
@@ -1,2 +0,0 @@
|
||||
/* eslint-disable */
|
||||
module.exports = require('./dist/src/config/database');
|
@@ -1,9 +0,0 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
setupFilesAfterEnv: ['./test/setup/global-hooks.ts'],
|
||||
globalTeardown: './test/setup/global-teardown.ts',
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: ['src/graphql/queries/*.ts'],
|
||||
};
|
@@ -1,7 +1,10 @@
|
||||
import { knexSnakeCaseMappers } from 'objection';
|
||||
import appConfig from './src/config/app';
|
||||
import appConfig from './src/config/app.js';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const fileExtension = appConfig.isDev || appConfig.isTest ? 'ts' : 'js';
|
||||
const fileExtension = 'js';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const knexConfig = {
|
||||
client: 'pg',
|
1
packages/backend/logger.d.ts
vendored
1
packages/backend/logger.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export * from './dist/src/helpers/logger';
|
@@ -1,2 +0,0 @@
|
||||
/* eslint-disable */
|
||||
module.exports = require('./dist/src/helpers/logger');
|
@@ -3,27 +3,23 @@
|
||||
"version": "0.10.0",
|
||||
"license": "See LICENSE file",
|
||||
"description": "The open source Zapier alternative. Build workflow automation without spending time and money.",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"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",
|
||||
"start": "node dist/src/server.js",
|
||||
"pretest": "APP_ENV=test ts-node ./test/setup/prepare-test-env.ts",
|
||||
"test": "APP_ENV=test jest --verbose",
|
||||
"dev": "nodemon --watch 'src/**/*.js' --exec 'node' src/server.js",
|
||||
"worker": "nodemon --watch 'src/**/*.js' --exec 'node' src/worker.js",
|
||||
"start": "node src/server.js",
|
||||
"start:worker": "node src/worker.js",
|
||||
"pretest": "APP_ENV=test node ./test/setup/prepare-test-env.js",
|
||||
"test": "APP_ENV=test vitest run",
|
||||
"lint": "eslint . --ignore-path ../../.eslintignore",
|
||||
"db:create": "ts-node ./bin/database/create.ts",
|
||||
"db:seed:user": "ts-node ./bin/database/seed-user.ts",
|
||||
"db:drop": "ts-node ./bin/database/drop.ts",
|
||||
"db:create": "node ./bin/database/create.js",
|
||||
"db:seed:user": "node ./bin/database/seed-user.js",
|
||||
"db:drop": "node ./bin/database/drop.js",
|
||||
"db:migration:create": "knex migrate:make",
|
||||
"db:rollback": "knex migrate:rollback",
|
||||
"db:migrate": "knex migrate:latest",
|
||||
"copy-statics": "copyfiles src/**/*.{graphql,json,svg,hbs} dist",
|
||||
"prepack": "yarn build",
|
||||
"prebuild": "rm -rf ./dist"
|
||||
"db:migrate": "node ./bin/database/convert-migrations.js && knex migrate:latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@automatisch/web": "^0.10.0",
|
||||
"@bull-board/express": "^3.10.1",
|
||||
"@casl/ability": "^6.5.0",
|
||||
"@graphql-tools/graphql-file-loader": "^7.3.4",
|
||||
@@ -32,28 +28,23 @@
|
||||
"@rudderstack/rudder-sdk-node": "^1.1.2",
|
||||
"@sentry/node": "^7.42.0",
|
||||
"@sentry/tracing": "^7.42.0",
|
||||
"@types/accounting": "^0.4.2",
|
||||
"@types/luxon": "^2.3.1",
|
||||
"@types/passport": "^1.0.12",
|
||||
"@types/xmlrpc": "^1.3.7",
|
||||
"accounting": "^0.4.1",
|
||||
"ajv-formats": "^2.1.1",
|
||||
"axios": "1.6.0",
|
||||
"bcrypt": "^5.0.1",
|
||||
"bullmq": "^3.0.0",
|
||||
"copyfiles": "^2.4.1",
|
||||
"cors": "^2.8.5",
|
||||
"crypto-js": "^4.1.1",
|
||||
"debug": "~2.6.9",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "~4.18.2",
|
||||
"express-async-handler": "^1.2.0",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"express-graphql": "^0.12.0",
|
||||
"fast-xml-parser": "^4.0.11",
|
||||
"graphql-middleware": "^6.1.15",
|
||||
"graphql-shield": "^7.5.0",
|
||||
"graphql-tools": "^8.2.0",
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"handlebars": "^4.7.7",
|
||||
"http-errors": "~1.6.3",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
@@ -76,7 +67,6 @@
|
||||
"pluralize": "^8.0.0",
|
||||
"raw-body": "^2.5.2",
|
||||
"showdown": "^2.1.0",
|
||||
"stripe": "^11.13.0",
|
||||
"winston": "^3.7.1",
|
||||
"xmlrpc": "^1.3.2"
|
||||
},
|
||||
@@ -87,26 +77,15 @@
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/automatisch/automatisch#readme",
|
||||
"main": "dist/src/app",
|
||||
"main": "src/server",
|
||||
"directories": {
|
||||
"bin": "bin",
|
||||
"src": "src",
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bin",
|
||||
"src",
|
||||
"server.js",
|
||||
"server.d.ts",
|
||||
"worker.js",
|
||||
"worker.d.ts",
|
||||
"logger.js",
|
||||
"logger.d.ts",
|
||||
"database.js",
|
||||
"database.d.ts",
|
||||
"database-utils.js",
|
||||
"database-utils.d.ts"
|
||||
"src"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -116,34 +95,10 @@
|
||||
"url": "https://github.com/automatisch/automatisch/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@automatisch/types": "^0.10.0",
|
||||
"@faker-js/faker": "^8.1.0",
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/bull": "^3.15.8",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/crypto-js": "^4.0.2",
|
||||
"@types/express": "^4.17.15",
|
||||
"@types/http-errors": "^1.8.1",
|
||||
"@types/jest": "^29.5.5",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"@types/lodash.get": "^4.4.6",
|
||||
"@types/memory-cache": "^0.2.2",
|
||||
"@types/morgan": "^1.9.3",
|
||||
"@types/multer": "1.4.7",
|
||||
"@types/node": "^16.10.2",
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@types/pg": "^8.6.1",
|
||||
"@types/pino": "^7.0.5",
|
||||
"@types/pluralize": "^0.0.30",
|
||||
"@types/showdown": "^2.0.1",
|
||||
"@types/supertest": "^2.0.14",
|
||||
"jest": "^29.7.0",
|
||||
"@typescript-eslint/utils": "^7.0.2",
|
||||
"nodemon": "^2.0.13",
|
||||
"sinon": "^11.1.2",
|
||||
"supertest": "^6.3.3",
|
||||
"ts-jest": "^29.1.1",
|
||||
"ts-node": "^10.2.1",
|
||||
"ts-node-dev": "^1.1.8"
|
||||
"vitest": "^1.1.3"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
1
packages/backend/server.d.ts
vendored
1
packages/backend/server.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export * from './dist/src/server';
|
@@ -1,2 +0,0 @@
|
||||
/* eslint-disable */
|
||||
module.exports = require('./dist/src/server.js');
|
@@ -2,22 +2,21 @@ import createError from 'http-errors';
|
||||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
|
||||
import { IRequest } from '@automatisch/types';
|
||||
import appConfig from './config/app';
|
||||
import corsOptions from './config/cors-options';
|
||||
import morgan from './helpers/morgan';
|
||||
import * as Sentry from './helpers/sentry.ee';
|
||||
import appAssetsHandler from './helpers/app-assets-handler';
|
||||
import webUIHandler from './helpers/web-ui-handler';
|
||||
import errorHandler from './helpers/error-handler';
|
||||
import './config/orm';
|
||||
import appConfig from './config/app.js';
|
||||
import corsOptions from './config/cors-options.js';
|
||||
import morgan from './helpers/morgan.js';
|
||||
import * as Sentry from './helpers/sentry.ee.js';
|
||||
import appAssetsHandler from './helpers/app-assets-handler.js';
|
||||
import webUIHandler from './helpers/web-ui-handler.js';
|
||||
import errorHandler from './helpers/error-handler.js';
|
||||
import './config/orm.js';
|
||||
import {
|
||||
createBullBoardHandler,
|
||||
serverAdapter,
|
||||
} from './helpers/create-bull-board-handler';
|
||||
import injectBullBoardHandler from './helpers/inject-bull-board-handler';
|
||||
import router from './routes';
|
||||
import configurePassport from './helpers/passport';
|
||||
} from './helpers/create-bull-board-handler.js';
|
||||
import injectBullBoardHandler from './helpers/inject-bull-board-handler.js';
|
||||
import router from './routes/index.js';
|
||||
import configurePassport from './helpers/passport.js';
|
||||
|
||||
createBullBoardHandler(serverAdapter);
|
||||
|
||||
@@ -38,7 +37,7 @@ app.use(
|
||||
express.json({
|
||||
limit: appConfig.requestBodySizeLimit,
|
||||
verify(req, res, buf) {
|
||||
(req as IRequest).rawBody = buf;
|
||||
req.rawBody = buf;
|
||||
},
|
||||
})
|
||||
);
|
||||
@@ -47,7 +46,7 @@ app.use(
|
||||
extended: true,
|
||||
limit: appConfig.requestBodySizeLimit,
|
||||
verify(req, res, buf) {
|
||||
(req as IRequest).rawBody = buf;
|
||||
req.rawBody = buf;
|
||||
},
|
||||
})
|
||||
);
|
3
packages/backend/src/apps/azure-openai/actions/index.js
Normal file
3
packages/backend/src/apps/azure-openai/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import sendPrompt from './send-prompt/index.js';
|
||||
|
||||
export default [sendPrompt];
|
@@ -1,3 +0,0 @@
|
||||
import sendPrompt from './send-prompt';
|
||||
|
||||
export default [sendPrompt];
|
@@ -0,0 +1,97 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
const castFloatOrUndefined = (value) => {
|
||||
return value === '' ? undefined : parseFloat(value);
|
||||
};
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send prompt',
|
||||
key: 'sendPrompt',
|
||||
description: 'Creates a completion for the provided prompt and parameters.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Prompt',
|
||||
key: 'prompt',
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'The text to analyze.',
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
key: 'temperature',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
'What sampling temperature to use, between 0 and 2. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend altering this or Top P but not both.',
|
||||
},
|
||||
{
|
||||
label: 'Maximum tokens',
|
||||
key: 'maxTokens',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
'The maximum number of tokens to generate in the completion.',
|
||||
},
|
||||
{
|
||||
label: 'Stop Sequence',
|
||||
key: 'stopSequence',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
'Single stop sequence where the API will stop generating further tokens. The returned text will not contain the stop sequence.',
|
||||
},
|
||||
{
|
||||
label: 'Top P',
|
||||
key: 'topP',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
'An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.',
|
||||
},
|
||||
{
|
||||
label: 'Frequency Penalty',
|
||||
key: 'frequencyPenalty',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: `Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.`,
|
||||
},
|
||||
{
|
||||
label: 'Presence Penalty',
|
||||
key: 'presencePenalty',
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: `Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.`,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const payload = {
|
||||
model: $.step.parameters.model,
|
||||
prompt: $.step.parameters.prompt,
|
||||
temperature: castFloatOrUndefined($.step.parameters.temperature),
|
||||
max_tokens: castFloatOrUndefined($.step.parameters.maxTokens),
|
||||
stop: $.step.parameters.stopSequence || null,
|
||||
top_p: castFloatOrUndefined($.step.parameters.topP),
|
||||
frequency_penalty: castFloatOrUndefined(
|
||||
$.step.parameters.frequencyPenalty
|
||||
),
|
||||
presence_penalty: castFloatOrUndefined($.step.parameters.presencePenalty),
|
||||
};
|
||||
|
||||
const { data } = await $.http.post(
|
||||
`/deployments/${$.auth.data.deploymentId}/completions`,
|
||||
payload
|
||||
);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,87 +0,0 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
const castFloatOrUndefined = (value: string | null) => {
|
||||
return value === '' ? undefined : parseFloat(value);
|
||||
}
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send prompt',
|
||||
key: 'sendPrompt',
|
||||
description: 'Creates a completion for the provided prompt and parameters.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Prompt',
|
||||
key: 'prompt',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'The text to analyze.'
|
||||
},
|
||||
{
|
||||
label: 'Temperature',
|
||||
key: 'temperature',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'What sampling temperature to use, between 0 and 2. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. We generally recommend altering this or Top P but not both.'
|
||||
},
|
||||
{
|
||||
label: 'Maximum tokens',
|
||||
key: 'maxTokens',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'The maximum number of tokens to generate in the completion.'
|
||||
},
|
||||
{
|
||||
label: 'Stop Sequence',
|
||||
key: 'stopSequence',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'Single stop sequence where the API will stop generating further tokens. The returned text will not contain the stop sequence.'
|
||||
},
|
||||
{
|
||||
label: 'Top P',
|
||||
key: 'topP',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.'
|
||||
},
|
||||
{
|
||||
label: 'Frequency Penalty',
|
||||
key: 'frequencyPenalty',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
variables: true,
|
||||
description: `Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.`
|
||||
},
|
||||
{
|
||||
label: 'Presence Penalty',
|
||||
key: 'presencePenalty',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
variables: true,
|
||||
description: `Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.`
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const payload = {
|
||||
model: $.step.parameters.model as string,
|
||||
prompt: $.step.parameters.prompt as string,
|
||||
temperature: castFloatOrUndefined($.step.parameters.temperature as string),
|
||||
max_tokens: castFloatOrUndefined($.step.parameters.maxTokens as string),
|
||||
stop: ($.step.parameters.stopSequence as string || null),
|
||||
top_p: castFloatOrUndefined($.step.parameters.topP as string),
|
||||
frequency_penalty: castFloatOrUndefined($.step.parameters.frequencyPenalty as string),
|
||||
presence_penalty: castFloatOrUndefined($.step.parameters.presencePenalty as string),
|
||||
};
|
||||
const { data } = await $.http.post(`/deployments/${$.auth.data.deploymentId}/completions`, payload);
|
||||
|
||||
$.setActionItem({
|
||||
raw: data,
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,12 +1,12 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
{
|
||||
key: 'yourResourceName',
|
||||
label: 'Your Resource Name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
{
|
||||
key: 'deploymentId',
|
||||
label: 'Deployment ID',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -42,7 +42,7 @@ export default {
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -0,0 +1,6 @@
|
||||
const isStillVerified = async ($) => {
|
||||
await $.http.get('/fine_tuning/jobs');
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,8 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await $.http.get('/fine_tuning/jobs');
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -0,0 +1,5 @@
|
||||
const verifyCredentials = async ($) => {
|
||||
await $.http.get('/fine_tuning/jobs');
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -1,7 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
await $.http.get('/fine_tuning/jobs');
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -0,0 +1,13 @@
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.apiKey) {
|
||||
requestConfig.headers['api-key'] = $.auth.data.apiKey;
|
||||
}
|
||||
|
||||
requestConfig.params = {
|
||||
'api-version': '2023-10-01-preview',
|
||||
};
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -1,15 +0,0 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data?.apiKey) {
|
||||
requestConfig.headers['api-key'] = $.auth.data.apiKey as string;
|
||||
}
|
||||
|
||||
requestConfig.params = {
|
||||
'api-version': '2023-10-01-preview'
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -0,0 +1,11 @@
|
||||
const setBaseUrl = ($, requestConfig) => {
|
||||
const yourResourceName = $.auth.data.yourResourceName;
|
||||
|
||||
if (yourResourceName) {
|
||||
requestConfig.baseURL = `https://${yourResourceName}.openai.azure.com/openai`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default setBaseUrl;
|
@@ -1,13 +0,0 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const setBaseUrl: TBeforeRequest = ($, requestConfig) => {
|
||||
const yourResourceName = $.auth.data.yourResourceName as string;
|
||||
|
||||
if (yourResourceName) {
|
||||
requestConfig.baseURL = `https://${yourResourceName}.openai.azure.com/openai`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default setBaseUrl;
|
@@ -1,13 +1,14 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import setBaseUrl from './common/set-base-url';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import setBaseUrl from './common/set-base-url.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Azure OpenAI',
|
||||
key: 'azure-openai',
|
||||
baseUrl: 'https://azure.microsoft.com/en-us/products/ai-services/openai-service',
|
||||
baseUrl:
|
||||
'https://azure.microsoft.com/en-us/products/ai-services/openai-service',
|
||||
apiBaseUrl: '',
|
||||
iconUrl: '{BASE_URL}/apps/azure-openai/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/azure-openai/connection',
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Add Template',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Templete Data',
|
||||
key: 'templateData',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'The content of your new Template in XML/HTML format.',
|
||||
@@ -17,7 +17,7 @@ export default defineAction({
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const templateData = $.step.parameters.templateData as string;
|
||||
const templateData = $.step.parameters.templateData;
|
||||
|
||||
const base64Data = Buffer.from(templateData).toString('base64');
|
||||
const dataURI = `data:application/xml;base64,${base64Data}`;
|
3
packages/backend/src/apps/carbone/actions/index.js
Normal file
3
packages/backend/src/apps/carbone/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import addTemplate from './add-template/index.js';
|
||||
|
||||
export default [addTemplate];
|
@@ -1,3 +0,0 @@
|
||||
import addTemplate from './add-template';
|
||||
|
||||
export default [addTemplate];
|
@@ -1,12 +1,12 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -0,0 +1,8 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
await $.http.get('/templates');
|
||||
|
||||
await $.auth.set({
|
@@ -1,6 +1,4 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.apiKey) {
|
||||
requestConfig.headers.Authorization = `Bearer ${$.auth.data.apiKey}`;
|
||||
requestConfig.headers['carbone-version'] = '4';
|
@@ -1,7 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Carbone',
|
3
packages/backend/src/apps/deepl/actions/index.js
Normal file
3
packages/backend/src/apps/deepl/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import translateText from './translate-text/index.js';
|
||||
|
||||
export default [translateText];
|
@@ -1,3 +0,0 @@
|
||||
import translateText from './translate-text';
|
||||
|
||||
export default [translateText];
|
@@ -1,5 +1,5 @@
|
||||
import qs from 'qs';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Translate text',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Text',
|
||||
key: 'text',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Text to be translated.',
|
||||
variables: true,
|
||||
@@ -17,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Target Language',
|
||||
key: 'targetLanguage',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: 'Language to translate the text to.',
|
||||
variables: true,
|
@@ -1,12 +1,12 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
{
|
||||
key: 'authenticationKey',
|
||||
label: 'Authentication Key',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -0,0 +1,8 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
await $.http.get('/v2/usage');
|
||||
|
||||
await $.auth.set({
|
@@ -1,6 +1,4 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.authenticationKey) {
|
||||
const authorizationHeader = `DeepL-Auth-Key ${$.auth.data.authenticationKey}`;
|
||||
requestConfig.headers.Authorization = authorizationHeader;
|
@@ -1,7 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'DeepL',
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Delay for',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Delay for unit',
|
||||
key: 'delayForUnit',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
value: null,
|
||||
description: 'Delay for unit, e.g. minutes, hours, days, weeks.',
|
||||
@@ -36,7 +36,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Delay for value',
|
||||
key: 'delayForValue',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Delay for value, use a number, e.g. 1, 2, 3.',
|
||||
variables: true,
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Delay until',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Delay until (Date)',
|
||||
key: 'delayUntil',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Delay until the date. E.g. 2022-12-18',
|
||||
variables: true,
|
4
packages/backend/src/apps/delay/actions/index.js
Normal file
4
packages/backend/src/apps/delay/actions/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import delayFor from './delay-for/index.js';
|
||||
import delayUntil from './delay-until/index.js';
|
||||
|
||||
export default [delayFor, delayUntil];
|
@@ -1,4 +0,0 @@
|
||||
import delayFor from './delay-for';
|
||||
import delayUntil from './delay-until';
|
||||
|
||||
export default [delayFor, delayUntil];
|
@@ -1,5 +1,5 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import actions from './actions';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Delay',
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create a scheduled event',
|
||||
@@ -8,13 +8,13 @@ export default defineAction({
|
||||
{
|
||||
label: 'Type',
|
||||
key: 'entityType',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
options: [
|
||||
{ label: 'Stage channel', value: 1 },
|
||||
{ label: 'Voice channel', value: 2 },
|
||||
{ label: 'External', value: 3 }
|
||||
{ label: 'External', value: 3 },
|
||||
],
|
||||
additionalFields: {
|
||||
type: 'query',
|
||||
@@ -34,61 +34,47 @@ export default defineAction({
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Description',
|
||||
key: 'description',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Image',
|
||||
key: 'image',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Image as DataURI scheme [data:image/<jpeg/png/gif>;base64,BASE64_ENCODED_<JPEG/PNG/GIF>_IMAGE_DATA]',
|
||||
description:
|
||||
'Image as DataURI scheme [data:image/<jpeg/png/gif>;base64,BASE64_ENCODED_<JPEG/PNG/GIF>_IMAGE_DATA]',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
type entity_metadata = {
|
||||
location: string
|
||||
}
|
||||
|
||||
type guild_event = {
|
||||
channel_id: number,
|
||||
name: string,
|
||||
privacy_level: number,
|
||||
scheduled_start_time: string,
|
||||
scheduled_end_time?: string,
|
||||
description?: string,
|
||||
entity_type?: number,
|
||||
entity_metadata?: entity_metadata,
|
||||
image?: string, //data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA
|
||||
}
|
||||
|
||||
|
||||
const data: guild_event = {
|
||||
channel_id: $.step.parameters.channel_id as number,
|
||||
name: $.step.parameters.name as string,
|
||||
const data = {
|
||||
channel_id: $.step.parameters.channel_id,
|
||||
name: $.step.parameters.name,
|
||||
privacy_level: 2,
|
||||
scheduled_start_time: $.step.parameters.scheduledStartTime as string,
|
||||
scheduled_end_time: $.step.parameters.scheduledEndTime as string,
|
||||
description: $.step.parameters.description as string,
|
||||
entity_type: $.step.parameters.entityType as number,
|
||||
image: $.step.parameters.image as string,
|
||||
scheduled_start_time: $.step.parameters.scheduledStartTime,
|
||||
scheduled_end_time: $.step.parameters.scheduledEndTime,
|
||||
description: $.step.parameters.description,
|
||||
entity_type: $.step.parameters.entityType,
|
||||
image: $.step.parameters.image,
|
||||
};
|
||||
|
||||
const isExternal = $.step.parameters.entityType === 3;
|
||||
|
||||
if (isExternal) {
|
||||
data.entity_metadata = {
|
||||
location: $.step.parameters.location as string,
|
||||
location: $.step.parameters.location,
|
||||
};
|
||||
|
||||
data.channel_id = null;
|
||||
}
|
||||
|
4
packages/backend/src/apps/discord/actions/index.js
Normal file
4
packages/backend/src/apps/discord/actions/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import sendMessageToChannel from './send-message-to-channel/index.js';
|
||||
import createScheduledEvent from './create-scheduled-event/index.js';
|
||||
|
||||
export default [sendMessageToChannel, createScheduledEvent];
|
@@ -1,4 +0,0 @@
|
||||
import sendMessageToChannel from './send-message-to-channel';
|
||||
import createScheduledEvent from './create-scheduled-event';
|
||||
|
||||
export default [sendMessageToChannel, createScheduledEvent];
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send a message to channel',
|
||||
@@ -8,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Channel',
|
||||
key: 'channel',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: 'Pick a channel to send the message to.',
|
||||
variables: true,
|
||||
@@ -26,7 +26,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Message text',
|
||||
key: 'message',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The content of your new message.',
|
||||
variables: true,
|
||||
@@ -35,8 +35,9 @@ export default defineAction({
|
||||
|
||||
async run($) {
|
||||
const data = {
|
||||
content: $.step.parameters.message as string,
|
||||
content: $.step.parameters.message,
|
||||
};
|
||||
|
||||
const response = await $.http?.post(
|
||||
`/channels/${$.step.parameters.channel}/messages`,
|
||||
data
|
@@ -1,15 +1,15 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import scopes from '../common/scopes';
|
||||
import scopes from '../common/scopes.js';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
export default async function generateAuthUrl($) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const callbackUrl = oauthRedirectUrlField.value as string;
|
||||
|
||||
const callbackUrl = oauthRedirectUrlField.value;
|
||||
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.consumerKey as string,
|
||||
client_id: $.auth.data.consumerKey,
|
||||
redirect_uri: callbackUrl,
|
||||
response_type: 'code',
|
||||
permissions: '2146958591',
|
@@ -1,13 +1,13 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import generateAuthUrl from './generate-auth-url.js';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/discord/connections/add',
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
{
|
||||
key: 'consumerKey',
|
||||
label: 'Consumer Key',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -32,7 +32,7 @@ export default {
|
||||
{
|
||||
key: 'consumerSecret',
|
||||
label: 'Consumer Secret',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
{
|
||||
key: 'botToken',
|
||||
label: 'Bot token',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -0,0 +1,9 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
await getCurrentUser($);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,10 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await getCurrentUser($);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,22 +1,24 @@
|
||||
import { IGlobalVariable, IField } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import scopes from '../common/scopes';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
import scopes from '../common/scopes.js';
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const callbackUrl = oauthRedirectUrlField.value as string;
|
||||
|
||||
const callbackUrl = oauthRedirectUrlField.value;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
client_id: $.auth.data.consumerKey as string,
|
||||
client_id: $.auth.data.consumerKey,
|
||||
redirect_uri: callbackUrl,
|
||||
response_type: 'code',
|
||||
scope: scopes.join(' '),
|
||||
client_secret: $.auth.data.consumerSecret as string,
|
||||
code: $.auth.data.code as string,
|
||||
client_secret: $.auth.data.consumerSecret,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
});
|
||||
|
||||
const { data: verifiedCredentials } = await $.http.post(
|
||||
'/oauth2/token',
|
||||
params.toString()
|
@@ -1,6 +1,4 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
const { tokenType, botToken } = $.auth.data;
|
||||
if (tokenType && botToken) {
|
||||
requestConfig.headers.Authorization = `Bot ${botToken}`;
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const getCurrentUser = async ($) => {
|
||||
const response = await $.http.get('/users/@me');
|
||||
const currentUser = response.data;
|
||||
|
4
packages/backend/src/apps/discord/dynamic-data/index.js
Normal file
4
packages/backend/src/apps/discord/dynamic-data/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import listChannels from './list-channels/index.js';
|
||||
import listVoiceChannels from './list-voice-channels/index.js';
|
||||
|
||||
export default [listChannels, listVoiceChannels];
|
@@ -1,4 +0,0 @@
|
||||
import listChannels from './list-channels';
|
||||
import listVoiceChannels from './list-voice-channels';
|
||||
|
||||
export default [listChannels, listVoiceChannels];
|
@@ -1,14 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List channels',
|
||||
key: 'listChannels',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const channels: {
|
||||
data: IJSONObject[];
|
||||
error: IJSONObject | null;
|
||||
} = {
|
||||
async run($) {
|
||||
const channels = {
|
||||
data: [],
|
||||
error: null,
|
||||
};
|
||||
@@ -18,11 +13,11 @@ export default {
|
||||
);
|
||||
|
||||
channels.data = response.data
|
||||
.filter((channel: IJSONObject) => {
|
||||
.filter((channel) => {
|
||||
// filter in text channels and announcement channels only
|
||||
return channel.type === 0 || channel.type === 5;
|
||||
})
|
||||
.map((channel: IJSONObject) => {
|
||||
.map((channel) => {
|
||||
return {
|
||||
value: channel.id,
|
||||
name: channel.name,
|
@@ -1,14 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List voice channels',
|
||||
key: 'listVoiceChannels',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const channels: {
|
||||
data: IJSONObject[];
|
||||
error: IJSONObject | null;
|
||||
} = {
|
||||
async run($) {
|
||||
const channels = {
|
||||
data: [],
|
||||
error: null,
|
||||
};
|
||||
@@ -18,11 +13,11 @@ export default {
|
||||
);
|
||||
|
||||
channels.data = response.data
|
||||
.filter((channel: IJSONObject) => {
|
||||
.filter((channel) => {
|
||||
// filter in voice and stage channels only
|
||||
return channel.type === 2 || channel.type === 13;
|
||||
})
|
||||
.map((channel: IJSONObject) => {
|
||||
.map((channel) => {
|
||||
return {
|
||||
value: channel.id,
|
||||
name: channel.name,
|
@@ -1,3 +1,3 @@
|
||||
import listExternalScheduledEventFields from './list-external-scheduled-event-fields';
|
||||
import listExternalScheduledEventFields from './list-external-scheduled-event-fields/index.js';
|
||||
|
||||
export default [listExternalScheduledEventFields];
|
@@ -1,9 +1,8 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
export default {
|
||||
name: 'List external scheduled event fields',
|
||||
key: 'listExternalScheduledEventFields',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const isExternal = $.step.parameters.entityType === 3;
|
||||
|
||||
if (isExternal) {
|
||||
@@ -11,15 +10,16 @@ export default {
|
||||
{
|
||||
label: 'Location',
|
||||
key: 'location',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The location of the event (1-100 characters). This will be omitted if type is NOT EXTERNAL',
|
||||
description:
|
||||
'The location of the event (1-100 characters). This will be omitted if type is NOT EXTERNAL',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Start-Time',
|
||||
key: 'scheduledStartTime',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The time the event will start [ISO8601]',
|
||||
variables: true,
|
||||
@@ -27,9 +27,10 @@ export default {
|
||||
{
|
||||
label: 'End-Time',
|
||||
key: 'scheduledEndTime',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The time the event will end [ISO8601]. This will be omitted if type is NOT EXTERNAL',
|
||||
description:
|
||||
'The time the event will end [ISO8601]. This will be omitted if type is NOT EXTERNAL',
|
||||
variables: true,
|
||||
},
|
||||
];
|
||||
@@ -39,9 +40,10 @@ export default {
|
||||
{
|
||||
label: 'Channel',
|
||||
key: 'channel_id',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: 'Pick a voice or stage channel to link the event to. This will be omitted if type is EXTERNAL',
|
||||
description:
|
||||
'Pick a voice or stage channel to link the event to. This will be omitted if type is EXTERNAL',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
@@ -57,15 +59,16 @@ export default {
|
||||
{
|
||||
label: 'Location',
|
||||
key: 'location',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'The location of the event (1-100 characters). This will be omitted if type is NOT EXTERNAL',
|
||||
description:
|
||||
'The location of the event (1-100 characters). This will be omitted if type is NOT EXTERNAL',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Start-Time',
|
||||
key: 'scheduledStartTime',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The time the event will start [ISO8601]',
|
||||
variables: true,
|
||||
@@ -73,9 +76,10 @@ export default {
|
||||
{
|
||||
label: 'End-Time',
|
||||
key: 'scheduledEndTime',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'The time the event will end [ISO8601]. This will be omitted if type is NOT EXTERNAL',
|
||||
description:
|
||||
'The time the event will end [ISO8601]. This will be omitted if type is NOT EXTERNAL',
|
||||
variables: true,
|
||||
},
|
||||
];
|
@@ -1,10 +1,10 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import dynamicData from './dynamic-data';
|
||||
import actions from './actions';
|
||||
import triggers from './triggers';
|
||||
import dynamicFields from './dynamic-fields';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
import actions from './actions/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import dynamicFields from './dynamic-fields/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Discord',
|
@@ -1,23 +1,25 @@
|
||||
import path from 'node:path';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create folder',
|
||||
key: 'createFolder',
|
||||
description: 'Create a new folder with the given parent folder and folder name',
|
||||
description:
|
||||
'Create a new folder with the given parent folder and folder name',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Folder',
|
||||
key: 'parentFolder',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Enter the parent folder path, like /TextFiles/ or /Documents/Taxes/',
|
||||
description:
|
||||
'Enter the parent folder path, like /TextFiles/ or /Documents/Taxes/',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Folder Name',
|
||||
key: 'folderName',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Enter the name for the new folder',
|
||||
variables: true,
|
||||
@@ -25,11 +27,13 @@ export default defineAction({
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const parentFolder = $.step.parameters.parentFolder as string;
|
||||
const folderName = $.step.parameters.folderName as string;
|
||||
const parentFolder = $.step.parameters.parentFolder;
|
||||
const folderName = $.step.parameters.folderName;
|
||||
const folderPath = path.join(parentFolder, folderName);
|
||||
|
||||
const response = await $.http.post('/2/files/create_folder_v2', { path: folderPath });
|
||||
const response = await $.http.post('/2/files/create_folder_v2', {
|
||||
path: folderPath,
|
||||
});
|
||||
|
||||
$.setActionItem({ raw: response.data });
|
||||
},
|
4
packages/backend/src/apps/dropbox/actions/index.js
Normal file
4
packages/backend/src/apps/dropbox/actions/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import createFolder from './create-folder/index.js';
|
||||
import renameFile from './rename-file/index.js';
|
||||
|
||||
export default [createFolder, renameFile];
|
@@ -1,4 +0,0 @@
|
||||
import createFolder from "./create-folder";
|
||||
import renameFile from "./rename-file";
|
||||
|
||||
export default [createFolder, renameFile];
|
@@ -1,5 +1,5 @@
|
||||
import path from 'node:path';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Rename file',
|
||||
@@ -9,25 +9,25 @@ export default defineAction({
|
||||
{
|
||||
label: 'File Path',
|
||||
key: 'filePath',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description:
|
||||
'Write the full path to the file such as /Folder1/File.pdf',
|
||||
description: 'Write the full path to the file such as /Folder1/File.pdf',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'New Name',
|
||||
key: 'newName',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: "Enter the new name for the file (without the extension, e.g., '.pdf')",
|
||||
description:
|
||||
"Enter the new name for the file (without the extension, e.g., '.pdf')",
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const filePath = $.step.parameters.filePath as string;
|
||||
const newName = $.step.parameters.newName as string;
|
||||
const filePath = $.step.parameters.filePath;
|
||||
const newName = $.step.parameters.newName;
|
||||
const fileObject = path.parse(filePath);
|
||||
const newPath = path.format({
|
||||
dir: fileObject.dir,
|
@@ -1,15 +1,15 @@
|
||||
import { URLSearchParams } from 'url';
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import scopes from '../common/scopes';
|
||||
import scopes from '../common/scopes.js';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
export default async function generateAuthUrl($) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const callbackUrl = oauthRedirectUrlField.value as string;
|
||||
|
||||
const callbackUrl = oauthRedirectUrlField.value;
|
||||
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId as string,
|
||||
client_id: $.auth.data.clientId,
|
||||
redirect_uri: callbackUrl,
|
||||
response_type: 'code',
|
||||
scope: scopes.join(' '),
|
@@ -1,14 +1,14 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import refreshToken from './refresh-token';
|
||||
import generateAuthUrl from './generate-auth-url.js';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
import refreshToken from './refresh-token.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/dropbox/connections/add',
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'App Key',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'App Secret',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user