chore(postgresql): rename app folder and add icon
This commit is contained in:
@@ -1,85 +0,0 @@
|
|||||||
import verifyCredentials from './verify-credentials';
|
|
||||||
import isStillVerified from './is-still-verified';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
key: 'version',
|
|
||||||
label: 'Postgres Version',
|
|
||||||
type: 'string' as const,
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'The version of postgres database that user want to connect with.',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'host',
|
|
||||||
label: 'Host',
|
|
||||||
type: 'string' as const,
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'The host of postgres database.',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'port',
|
|
||||||
label: 'Port',
|
|
||||||
type: 'string' as const,
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'The port of postgres database.',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'database',
|
|
||||||
label: 'Database Name',
|
|
||||||
type: 'string' as const,
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'The name of postgres database.',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'user',
|
|
||||||
label: 'Database User Name',
|
|
||||||
type: 'string' as const,
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'The user who has access on postgres database.',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'password',
|
|
||||||
label: 'Password',
|
|
||||||
type: 'string' as const,
|
|
||||||
required: true,
|
|
||||||
readOnly: false,
|
|
||||||
value: null,
|
|
||||||
placeholder: null,
|
|
||||||
description:
|
|
||||||
'The password of the user.',
|
|
||||||
clickToCopy: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
verifyCredentials,
|
|
||||||
isStillVerified
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@@ -1,22 +0,0 @@
|
|||||||
// import { IGlobalVariable } from '@automatisch/types';
|
|
||||||
// import verifyCredentials from './verify-credentials';
|
|
||||||
// import { Knex } from 'knex';
|
|
||||||
|
|
||||||
// const isStillVerified = async ($: IGlobalVariable) => {
|
|
||||||
|
|
||||||
// await $.auth.data.pgClient.raw('SELECT 1')
|
|
||||||
// // await verifyCredentials($);
|
|
||||||
// return true;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// export default isStillVerified;
|
|
||||||
|
|
||||||
import { IGlobalVariable } from '@automatisch/types';
|
|
||||||
import verifyCredentials from './verify-credentials';
|
|
||||||
|
|
||||||
const isStillVerified = async ($: IGlobalVariable) => {
|
|
||||||
await verifyCredentials($);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default isStillVerified;
|
|
@@ -1,57 +0,0 @@
|
|||||||
import { IGlobalVariable } from '@automatisch/types';
|
|
||||||
import logger from '../../../helpers/logger';
|
|
||||||
import setConfig from '../common/postgres-configuration';
|
|
||||||
|
|
||||||
|
|
||||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
|
||||||
|
|
||||||
const pgClient = await setConfig($)
|
|
||||||
const checkConnection = await pgClient.raw('SELECT 1')
|
|
||||||
logger.debug(checkConnection)
|
|
||||||
|
|
||||||
await $.auth.set({
|
|
||||||
screenName: `${$.auth.data.database} DB`,
|
|
||||||
client: 'pg',
|
|
||||||
version: $.auth.data.version,
|
|
||||||
host : $.auth.data.host,
|
|
||||||
port : $.auth.data.port,
|
|
||||||
user : $.auth.data.user,
|
|
||||||
password : $.auth.data.password,
|
|
||||||
database : $.auth.data.database
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default verifyCredentials;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
mutation Login($input: LoginInput) { login(input: $input) { token user { id email __typename } __typename }}
|
|
||||||
|
|
||||||
|
|
||||||
mutation CreateConnection($input: CreateConnectionInput) { createConnection(input: $input) { id key verified formattedData { screenName __typename } __typename }}
|
|
||||||
|
|
||||||
{
|
|
||||||
"input":
|
|
||||||
{
|
|
||||||
"key": "postgres",
|
|
||||||
"formattedData": {
|
|
||||||
"version":"15",
|
|
||||||
"host":"127.0.0.1",
|
|
||||||
"port":"6500",
|
|
||||||
"database":"bbs",
|
|
||||||
"user":"test",
|
|
||||||
"password":"@Test123"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mutation VerifyConnection($input: VerifyConnectionInput) { verifyConnection(input: $input) { id key verified formattedData { screenName __typename } createdAt app { key __typename } __typename }}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
"input":
|
|
||||||
{"id": "18309778-ef78-41ae-be1b-ff51781134c0"}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
@@ -1,22 +0,0 @@
|
|||||||
import { IGlobalVariable } from '@automatisch/types';
|
|
||||||
import knex, { Knex } from 'knex'
|
|
||||||
|
|
||||||
|
|
||||||
const setConfig = async ($: IGlobalVariable) : Promise<Knex<any, unknown[]>> => {
|
|
||||||
const pgClient = knex({
|
|
||||||
client: 'pg',
|
|
||||||
version: $.auth.data.version as string,
|
|
||||||
connection: {
|
|
||||||
host : $.auth.data.host as string,
|
|
||||||
port : $.auth.data.port as number,
|
|
||||||
user : $.auth.data.user as string,
|
|
||||||
password : $.auth.data.password as string,
|
|
||||||
database : $.auth.data.database as string
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return pgClient;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export default setConfig;
|
|
@@ -1,17 +0,0 @@
|
|||||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
|
||||||
import { Knex } from 'knex'
|
|
||||||
import logger from '../../../helpers/logger';
|
|
||||||
|
|
||||||
const setParams = async ($: IGlobalVariable, client: Knex<any, unknown[]>) : Promise<Knex.Raw<any>> => {
|
|
||||||
|
|
||||||
const params : any = $.step.parameters.params
|
|
||||||
let paramsObj : IJSONObject = {}
|
|
||||||
params.forEach( (ele: any) => { paramsObj[ele.configParam] = ele.value } )
|
|
||||||
|
|
||||||
for (const key in paramsObj) {
|
|
||||||
const res = await client.raw(`SET ${key} = '${paramsObj[key]}'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export default setParams;
|
|
@@ -1,17 +0,0 @@
|
|||||||
import defineApp from '../../helpers/define-app';
|
|
||||||
import auth from './auth';
|
|
||||||
import actions from './actions';
|
|
||||||
|
|
||||||
export default defineApp({
|
|
||||||
name: 'PostgreSQL DataBase',
|
|
||||||
key: 'postgres',
|
|
||||||
iconUrl: '{BASE_URL}/apps/thecatapi/assets/favicon.svg',
|
|
||||||
authDocUrl: 'https://automatisch.io/docs/apps/thecatapi/connection',
|
|
||||||
supportsConnections: true,
|
|
||||||
baseUrl: '', // https://thecatapi.com
|
|
||||||
apiBaseUrl: '', // https://api.thecatapi.com
|
|
||||||
primaryColor: '000000',
|
|
||||||
|
|
||||||
auth,
|
|
||||||
actions
|
|
||||||
});
|
|
@@ -1,6 +1,6 @@
|
|||||||
import { IJSONObject, IJSONArray } from '@automatisch/types';
|
import { IJSONObject, IJSONArray } from '@automatisch/types';
|
||||||
import defineAction from '../../../../helpers/define-action';
|
import defineAction from '../../../../helpers/define-action';
|
||||||
import setConfig from '../../common/postgres-configuration';
|
import setConfig from '../../common/postgres-client';
|
||||||
import setParams from '../../common/set-run-time-parameters';
|
import setParams from '../../common/set-run-time-parameters';
|
||||||
|
|
||||||
export default defineAction({
|
export default defineAction({
|
@@ -1,6 +1,6 @@
|
|||||||
import { IJSONObject } from '@automatisch/types';
|
import { IJSONObject } from '@automatisch/types';
|
||||||
import defineAction from '../../../../helpers/define-action';
|
import defineAction from '../../../../helpers/define-action';
|
||||||
import setConfig from '../../common/postgres-configuration';
|
import setConfig from '../../common/postgres-client';
|
||||||
import setParams from '../../common/set-run-time-parameters';
|
import setParams from '../../common/set-run-time-parameters';
|
||||||
|
|
||||||
export default defineAction({
|
export default defineAction({
|
@@ -1,6 +1,6 @@
|
|||||||
import { IJSONObject } from '@automatisch/types';
|
import { IJSONObject } from '@automatisch/types';
|
||||||
import defineAction from '../../../../helpers/define-action';
|
import defineAction from '../../../../helpers/define-action';
|
||||||
import setConfig from '../../common/postgres-configuration';
|
import setConfig from '../../common/postgres-client';
|
||||||
import setParams from '../../common/set-run-time-parameters';
|
import setParams from '../../common/set-run-time-parameters';
|
||||||
|
|
||||||
export default defineAction({
|
export default defineAction({
|
@@ -1,6 +1,6 @@
|
|||||||
import { IJSONObject, IJSONArray } from '@automatisch/types';
|
import { IJSONObject, IJSONArray } from '@automatisch/types';
|
||||||
import defineAction from '../../../../helpers/define-action';
|
import defineAction from '../../../../helpers/define-action';
|
||||||
import setConfig from '../../common/postgres-configuration';
|
import setConfig from '../../common/postgres-client';
|
||||||
import setParams from '../../common/set-run-time-parameters';
|
import setParams from '../../common/set-run-time-parameters';
|
||||||
|
|
||||||
export default defineAction({
|
export default defineAction({
|
10
packages/backend/src/apps/postgresql/assets/favicon.svg
Normal file
10
packages/backend/src/apps/postgresql/assets/favicon.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 13 KiB |
75
packages/backend/src/apps/postgresql/auth/index.ts
Normal file
75
packages/backend/src/apps/postgresql/auth/index.ts
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import verifyCredentials from './verify-credentials';
|
||||||
|
import isStillVerified from './is-still-verified';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
key: 'version',
|
||||||
|
label: 'PostgreSQL version',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description:
|
||||||
|
'The version of PostgreSQL database that user want to connect with.',
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'host',
|
||||||
|
label: 'Host',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: '127.0.0.1',
|
||||||
|
placeholder: null,
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'port',
|
||||||
|
label: 'Port',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: '5432',
|
||||||
|
placeholder: null,
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'database',
|
||||||
|
label: 'Database Name',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
label: 'Database username',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description:
|
||||||
|
'The user who has access on postgres database.',
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'password',
|
||||||
|
label: 'Password',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
clickToCopy: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
verifyCredentials,
|
||||||
|
isStillVerified
|
||||||
|
};
|
@@ -0,0 +1,10 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
import verifyCredentials from './verify-credentials';
|
||||||
|
|
||||||
|
const isStillVerified = async ($: IGlobalVariable) => {
|
||||||
|
await verifyCredentials($);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default isStillVerified;
|
@@ -0,0 +1,23 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
import logger from '../../../helpers/logger';
|
||||||
|
import getClient from '../common/postgres-client';
|
||||||
|
|
||||||
|
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||||
|
const pgClient = getClient($);
|
||||||
|
const checkConnection = await pgClient.raw('SELECT 1');
|
||||||
|
|
||||||
|
logger.debug(checkConnection);
|
||||||
|
|
||||||
|
await $.auth.set({
|
||||||
|
screenName: `${$.auth.data.user}@${$.auth.data.host}:${$.auth.data.port}/${$.auth.data.database}`,
|
||||||
|
client: 'pg',
|
||||||
|
version: $.auth.data.version,
|
||||||
|
host: $.auth.data.host,
|
||||||
|
port: Number($.auth.data.port),
|
||||||
|
user: $.auth.data.user,
|
||||||
|
password: $.auth.data.password,
|
||||||
|
database: $.auth.data.database
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default verifyCredentials;
|
@@ -0,0 +1,20 @@
|
|||||||
|
import knex, { Knex } from 'knex';
|
||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
|
||||||
|
const getClient = ($: IGlobalVariable): Knex<any, unknown[]> => {
|
||||||
|
const pgClient = knex({
|
||||||
|
client: 'pg',
|
||||||
|
version: $.auth.data.version as string,
|
||||||
|
connection: {
|
||||||
|
host: $.auth.data.host as string,
|
||||||
|
port: Number($.auth.data.port),
|
||||||
|
user: $.auth.data.user as string,
|
||||||
|
password: $.auth.data.password as string,
|
||||||
|
database: $.auth.data.database as string,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return pgClient;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getClient;
|
@@ -0,0 +1,16 @@
|
|||||||
|
import { Knex } from 'knex';
|
||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
const setParams = async ($: IGlobalVariable, client: Knex<any, unknown[]>): Promise<Knex.Raw<any>> => {
|
||||||
|
|
||||||
|
const params: any = $.step.parameters.params
|
||||||
|
let paramsObj: IJSONObject = {}
|
||||||
|
params.forEach((ele: any) => { paramsObj[ele.configParam] = ele.value })
|
||||||
|
|
||||||
|
for (const key in paramsObj) {
|
||||||
|
const res = await client.raw(`SET ${key} = '${paramsObj[key]}'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
export default setParams;
|
17
packages/backend/src/apps/postgresql/index.ts
Normal file
17
packages/backend/src/apps/postgresql/index.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import defineApp from '../../helpers/define-app';
|
||||||
|
import auth from './auth';
|
||||||
|
import actions from './actions';
|
||||||
|
|
||||||
|
export default defineApp({
|
||||||
|
name: 'PostgreSQL database',
|
||||||
|
key: 'postgresql',
|
||||||
|
iconUrl: '{BASE_URL}/apps/postgresql/assets/favicon.svg',
|
||||||
|
authDocUrl: 'https://automatisch.io/docs/apps/postgresql/connection',
|
||||||
|
supportsConnections: true,
|
||||||
|
baseUrl: '',
|
||||||
|
apiBaseUrl: '',
|
||||||
|
primaryColor: '336791',
|
||||||
|
|
||||||
|
auth,
|
||||||
|
actions
|
||||||
|
});
|
Reference in New Issue
Block a user