Compare commits

...

75 Commits

Author SHA1 Message Date
Rıdvan Akca
465dc8ba38 feat(notion): add update database item action 2024-01-15 18:20:13 +03:00
Ömer Faruk Aydın
1e3ab75bb7 Merge pull request #1538 from automatisch/remove-types-package
chore: Remove types package
2024-01-15 13:57:01 +01:00
Faruk AYDIN
5f6dd12a73 chore: Remove types package from web dependencies 2024-01-15 13:41:54 +01:00
Faruk AYDIN
d18c06d2c4 chore: Remove types package 2024-01-15 13:37:58 +01:00
Ömer Faruk Aydın
baf99a9cfe Merge pull request #1537 from automatisch/web/types
chore: Use types from the web package
2024-01-15 13:37:43 +01:00
Faruk AYDIN
159931a6ea chore: Use types from the web package 2024-01-15 13:30:48 +01:00
Ömer Faruk Aydın
7831f2925b Merge pull request #1536 from automatisch/docs/remove-typescript
Use JS for the documentation examples
2024-01-15 13:17:48 +01:00
Faruk AYDIN
8fcb7840de docs: Convert code examples to JS 2024-01-15 13:13:48 +01:00
Faruk AYDIN
9ece9461dc docs: Convert all file imports to ES modules 2024-01-15 13:10:26 +01:00
Faruk AYDIN
b304acaaba docs: Use .js file extension 2024-01-15 13:02:06 +01:00
Faruk AYDIN
5a1960609a docs: Use JS highlighter instead of TS 2024-01-15 12:56:43 +01:00
Faruk AYDIN
476aa6e3aa docs: Remove imports of automatisch types 2024-01-15 12:55:55 +01:00
Ömer Faruk Aydın
aa76007fd0 Merge pull request #1533 from automatisch/remove-cli
chore: Remove cli package
2024-01-14 21:06:46 +01:00
Faruk AYDIN
17a8813c4b chore: Remove build step from CI for cli 2024-01-14 20:13:23 +01:00
Faruk AYDIN
fe79fc9003 chore: Remove cli package 2024-01-14 20:10:23 +01:00
Ömer Faruk Aydın
ac8649ac18 Merge pull request #1532 from automatisch/seed-user
fix: Exit process after creating seed user
2024-01-13 03:07:05 +01:00
Faruk AYDIN
817db026b1 fix: Exit process after creating database and user 2024-01-13 02:59:00 +01:00
Faruk AYDIN
01ef97949b feat: Convert migration file names if there is a table 2024-01-13 02:58:28 +01:00
Faruk AYDIN
9e151051a8 fix: Exit process after creating seed user 2024-01-13 02:55:42 +01:00
Ömer Faruk Aydın
0feab23eb6 Merge pull request #1531 from automatisch/dockerfile-cloud
fix: Remove redundant branch tag for dockerfile cloud
2024-01-12 18:12:48 +01:00
Faruk AYDIN
8957f83939 fix: Remove redundant branch tag for dockerfile cloud 2024-01-12 18:08:55 +01:00
Ömer Faruk Aydın
3bf2bc94f3 Merge pull request #1517 from automatisch/models-js
feat: Convert model files to JS
2024-01-12 18:05:44 +01:00
Faruk AYDIN
8c3d5f1f4b feat: Convert old TS migration names to JS names 2024-01-12 17:50:09 +01:00
Faruk AYDIN
124e6e0811 feat: Execute db:migrate and db:seed:user for main instance 2024-01-12 17:30:05 +01:00
Faruk AYDIN
54d9d17d14 chore: Make dockerfile cloud work with main branch 2024-01-12 17:24:29 +01:00
Faruk AYDIN
62bdb7fb6d fix: Import statements of removed subscription job 2024-01-12 16:44:56 +01:00
Faruk AYDIN
af6574fdf1 feat: Do not build web when it's a worker instance 2024-01-12 16:44:44 +01:00
Faruk AYDIN
115a993cd2 feat: Convert cloud dockerfile to work without build step 2024-01-12 16:33:58 +01:00
Faruk AYDIN
188b6c2fe5 chore: Remove @automatisch/web from backend package 2024-01-12 16:10:37 +01:00
Faruk AYDIN
99adb2ceda feat: Update node version to 18 for Dockerfiles 2024-01-12 15:17:09 +01:00
Faruk AYDIN
6344a3bcef feat: Remove jest from dev dependencies 2024-01-12 14:23:03 +01:00
Faruk AYDIN
f62c17de0b fix: Remove redundant only statement from backend tests 2024-01-12 14:22:19 +01:00
Faruk AYDIN
9d269b8111 chore: Change CI node version to 18 2024-01-12 14:19:29 +01:00
Faruk AYDIN
49b26a9640 chore: Remove tsconfig file for backend package 2024-01-12 14:15:39 +01:00
Faruk AYDIN
dddb79eeb2 chore: Remove ts-jest from dev dependencies 2024-01-12 14:14:30 +01:00
Faruk AYDIN
b0909ecb98 chore: Change main and files of backend package 2024-01-12 14:13:45 +01:00
Faruk AYDIN
ec63ce0532 chore: Remove sinon from dependencies 2024-01-12 14:13:26 +01:00
Faruk AYDIN
1eb03e3afb chore: Remove all dev dependencies for types 2024-01-12 14:10:58 +01:00
Faruk AYDIN
26d906f1b7 chore: Remove ts-node and ts-node-dev libraries 2024-01-12 14:09:00 +01:00
Faruk AYDIN
af9ceac0b4 feat: Use vitest instead of jest for ESM compatibility 2024-01-12 14:07:59 +01:00
Faruk AYDIN
911159a14f chore: Update NodeJS from 16.15 to 18.19 to use vitest 2024-01-11 19:37:00 +01:00
Faruk AYDIN
6a639e4ac9 chore: Use ES module path to import auth files 2024-01-09 12:51:41 +01:00
Faruk AYDIN
c4a6c86a69 feat: Make web app path static for the backend 2024-01-08 18:36:36 +01:00
Faruk AYDIN
d2bac9d8d1 chore: Adjust cli package to use JS for linter 2024-01-08 17:23:06 +01:00
Faruk AYDIN
758aa50550 feat: Change playwright test setup for the backend 2024-01-08 17:20:03 +01:00
Faruk AYDIN
1af887cee7 chore: Remove backend build step from cli build 2024-01-08 17:11:26 +01:00
Faruk AYDIN
34b115c694 feat: Convert cli files to JS 2024-01-08 17:08:20 +01:00
Faruk AYDIN
8e4935409f feat: Add start worker CI step for the backend package 2024-01-08 16:40:20 +01:00
Faruk AYDIN
ca32d221c4 fix: Remove redundant lerna bootstrap command 2024-01-08 16:35:04 +01:00
Faruk AYDIN
e2de1fe038 feat: Add webhook secret key to CI step 2024-01-08 16:26:25 +01:00
Faruk AYDIN
80179062db feat: Add sample encryption key to CI step 2024-01-08 16:15:47 +01:00
Faruk AYDIN
7143620d25 feat: Remove root files for worker, server, logger and database 2024-01-08 16:09:58 +01:00
Faruk AYDIN
a0e51e2a7e feat: Change CI configuration to start backend instead of build 2024-01-08 16:02:48 +01:00
Faruk AYDIN
53dbd01cb1 feat: Adjust start command to work without dist folder 2024-01-08 15:55:53 +01:00
Faruk AYDIN
3607c16fd1 chore: Remove build:watch script from backend 2024-01-08 15:55:29 +01:00
Faruk AYDIN
4dfdd01295 chore: Remove build and related scripts from backend 2024-01-08 15:54:32 +01:00
Faruk AYDIN
8983a3c581 chore: Remove types folder of the backend package 2024-01-08 15:53:41 +01:00
Faruk AYDIN
9cddef9108 fix: Adjust migrations folder for new JS structure 2024-01-08 14:49:30 +01:00
Faruk AYDIN
3dbea953a7 chore: Remove tsc command from build script 2024-01-08 14:49:14 +01:00
Faruk AYDIN
962bbc04b5 fix: Change require.resolve to work with ESM 2024-01-08 12:25:21 +01:00
Faruk AYDIN
0804026d74 fix: Correct dirname for the app config 2024-01-08 12:24:53 +01:00
Faruk AYDIN
879aa1f9f8 fix: Eslint offenses for JS files 2024-01-07 20:09:36 +01:00
Faruk AYDIN
9ffe2c14df chore: Exclude apps folder from type roots 2024-01-07 19:38:07 +01:00
Faruk AYDIN
f0d2f07193 feat: Convert package scripts to work with JS 2024-01-07 19:36:44 +01:00
Faruk AYDIN
ccf5928262 feat: Adjust eslint configuration to work with JS 2024-01-07 19:33:18 +01:00
Faruk AYDIN
b2f8634008 chore: Use ES modules for backend app 2024-01-05 19:08:04 +01:00
Faruk AYDIN
43dba351c3 feat: Convert all app files to JS 2024-01-05 17:44:21 +01:00
Faruk AYDIN
b95478b635 chore: Use imports as ES modules 2024-01-04 22:24:42 +01:00
Faruk AYDIN
523f8a8951 feat: Convert app, server, worker ts files to JS 2024-01-04 21:47:34 +01:00
Faruk AYDIN
0f71924d06 feat: Convert migration files to JS 2024-01-04 21:44:40 +01:00
Faruk AYDIN
6d1bfc0be0 fix: Remove response data types to get rid of ts errors 2024-01-04 21:17:15 +01:00
Faruk AYDIN
b0f53268f6 feat: Convert factories files to JS 2024-01-04 21:10:42 +01:00
Faruk AYDIN
75f5db23df feat: Conveert bin folder to use JS files 2024-01-04 21:07:19 +01:00
Faruk AYDIN
85141812d9 feat: Convert helpers to use JS files 2024-01-04 19:55:41 +01:00
Faruk AYDIN
8819ddefa7 feat: Convert model files to JS 2024-01-04 19:27:13 +01:00
1439 changed files with 8025 additions and 28568 deletions

View File

@@ -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 }}."

View File

@@ -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

View File

@@ -1 +1 @@
16.15.0
18.19.0

2
.nvmrc
View File

@@ -1 +1 @@
16.15.0
18.19.0

View File

@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
FROM node:16-alpine
FROM node:18-alpine
WORKDIR /automatisch
RUN \

View File

@@ -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

View File

@@ -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

View File

@@ -18,7 +18,6 @@
"**/babel-loader",
"**/webpack",
"**/@automatisch/web",
"**/@automatisch/types",
"**/ajv"
]
},

View File

@@ -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'],
},
},
],
};

View File

@@ -0,0 +1,12 @@
{
"root": true,
"env": {
"node": true,
"es6": true
},
"extends": ["eslint:recommended", "prettier"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
}
}

View File

@@ -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,

View 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();

View File

@@ -0,0 +1,3 @@
import { createDatabaseAndUser } from './utils.js';
createDatabaseAndUser();

View File

@@ -1,3 +0,0 @@
import { createDatabaseAndUser } from './utils';
createDatabaseAndUser();

View File

@@ -0,0 +1,3 @@
import { dropDatabase } from './utils.js';
dropDatabase();

View File

@@ -1,3 +0,0 @@
import { dropDatabase } from './utils';
dropDatabase();

View File

@@ -0,0 +1,3 @@
import { createUser } from './utils.js';
createUser();

View File

@@ -1,3 +0,0 @@
import { createUser } from './utils';
createUser();

View File

@@ -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;
}

View File

@@ -1 +0,0 @@
export * from './dist/bin/database/utils';

View File

@@ -1,2 +0,0 @@
/* eslint-disable */
module.exports = require('./dist/bin/database/utils');

View File

@@ -1 +0,0 @@
export * from './dist/src/config/database';

View File

@@ -1,2 +0,0 @@
/* eslint-disable */
module.exports = require('./dist/src/config/database');

View File

@@ -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'],
};

View File

@@ -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',

View File

@@ -1 +0,0 @@
export * from './dist/src/helpers/logger';

View File

@@ -1,2 +0,0 @@
/* eslint-disable */
module.exports = require('./dist/src/helpers/logger');

View File

@@ -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,10 +28,6 @@
"@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",
@@ -87,26 +79,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 +97,9 @@
"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",
"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"

View File

@@ -1 +0,0 @@
export * from './dist/src/server';

View File

@@ -1,2 +0,0 @@
/* eslint-disable */
module.exports = require('./dist/src/server.js');

View File

@@ -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;
},
})
);

View File

@@ -0,0 +1,3 @@
import sendPrompt from './send-prompt/index.js';
export default [sendPrompt];

View File

@@ -1,3 +0,0 @@
import sendPrompt from './send-prompt';
export default [sendPrompt];

View File

@@ -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,
});
},
});

View File

@@ -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,
});
},
});

View File

@@ -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,

View File

@@ -0,0 +1,6 @@
const isStillVerified = async ($) => {
await $.http.get('/fine_tuning/jobs');
return true;
};
export default isStillVerified;

View File

@@ -1,8 +0,0 @@
import { IGlobalVariable } from '@automatisch/types';
const isStillVerified = async ($: IGlobalVariable) => {
await $.http.get('/fine_tuning/jobs');
return true;
};
export default isStillVerified;

View File

@@ -0,0 +1,5 @@
const verifyCredentials = async ($) => {
await $.http.get('/fine_tuning/jobs');
};
export default verifyCredentials;

View File

@@ -1,7 +0,0 @@
import { IGlobalVariable } from '@automatisch/types';
const verifyCredentials = async ($: IGlobalVariable) => {
await $.http.get('/fine_tuning/jobs');
};
export default verifyCredentials;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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',

View File

@@ -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}`;

View File

@@ -0,0 +1,3 @@
import addTemplate from './add-template/index.js';
export default [addTemplate];

View File

@@ -1,3 +0,0 @@
import addTemplate from './add-template';
export default [addTemplate];

View File

@@ -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,

View File

@@ -0,0 +1,8 @@
import verifyCredentials from './verify-credentials.js';
const isStillVerified = async ($) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -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;

View File

@@ -1,6 +1,4 @@
import { IGlobalVariable } from '@automatisch/types';
const verifyCredentials = async ($: IGlobalVariable) => {
const verifyCredentials = async ($) => {
await $.http.get('/templates');
await $.auth.set({

View File

@@ -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';

View File

@@ -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',

View File

@@ -0,0 +1,3 @@
import translateText from './translate-text/index.js';
export default [translateText];

View File

@@ -1,3 +0,0 @@
import translateText from './translate-text';
export default [translateText];

View File

@@ -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,

View File

@@ -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,

View File

@@ -0,0 +1,8 @@
import verifyCredentials from './verify-credentials.js';
const isStillVerified = async ($) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -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;

View File

@@ -1,6 +1,4 @@
import { IGlobalVariable } from '@automatisch/types';
const verifyCredentials = async ($: IGlobalVariable) => {
const verifyCredentials = async ($) => {
await $.http.get('/v2/usage');
await $.auth.set({

View File

@@ -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;

View File

@@ -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',

View File

@@ -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,

View File

@@ -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,

View File

@@ -0,0 +1,4 @@
import delayFor from './delay-for/index.js';
import delayUntil from './delay-until/index.js';
export default [delayFor, delayUntil];

View File

@@ -1,4 +0,0 @@
import delayFor from './delay-for';
import delayUntil from './delay-until';
export default [delayFor, delayUntil];

View File

@@ -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',

View File

@@ -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;
}

View 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];

View File

@@ -1,4 +0,0 @@
import sendMessageToChannel from './send-message-to-channel';
import createScheduledEvent from './create-scheduled-event';
export default [sendMessageToChannel, createScheduledEvent];

View File

@@ -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

View File

@@ -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',

View File

@@ -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,

View File

@@ -0,0 +1,9 @@
import getCurrentUser from '../common/get-current-user.js';
const isStillVerified = async ($) => {
await getCurrentUser($);
return true;
};
export default isStillVerified;

View File

@@ -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;

View File

@@ -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()

View File

@@ -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}`;

View File

@@ -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;

View File

@@ -0,0 +1,4 @@
import listChannels from './list-channels/index.js';
import listVoiceChannels from './list-voice-channels/index.js';
export default [listChannels, listVoiceChannels];

View File

@@ -1,4 +0,0 @@
import listChannels from './list-channels';
import listVoiceChannels from './list-voice-channels';
export default [listChannels, listVoiceChannels];

View File

@@ -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,

View File

@@ -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,

View File

@@ -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];

View File

@@ -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,
},
];

View File

@@ -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',

View File

@@ -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 });
},

View File

@@ -0,0 +1,4 @@
import createFolder from './create-folder/index.js';
import renameFile from './rename-file/index.js';
export default [createFolder, renameFile];

View File

@@ -1,4 +0,0 @@
import createFolder from "./create-folder";
import renameFile from "./rename-file";
export default [createFolder, renameFile];

View File

@@ -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,

View File

@@ -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(' '),

View File

@@ -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,

View File

@@ -0,0 +1,8 @@
import getCurrentAccount from '../common/get-current-account.js';
const isStillVerified = async ($) => {
const account = await getCurrentAccount($);
return !!account;
};
export default isStillVerified;

Some files were not shown because too many files have changed in this diff Show More