From 5257fe7bf7a1fb7347d61017fe4f31b3b65037ab Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Mon, 8 Nov 2021 22:08:47 +0000 Subject: [PATCH] Integrate with UI --- packages/builder/assets/oracle.png | Bin 0 -> 8532 bytes .../DatasourceNavigator/icons/Oracle.svelte | 16 ++ .../DatasourceNavigator/icons/index.js | 2 + packages/builder/src/constants/index.js | 1 + packages/server/src/integrations/oracle.ts | 147 +++++------------- 5 files changed, 62 insertions(+), 104 deletions(-) create mode 100644 packages/builder/assets/oracle.png create mode 100644 packages/builder/src/components/backend/DatasourceNavigator/icons/Oracle.svelte diff --git a/packages/builder/assets/oracle.png b/packages/builder/assets/oracle.png new file mode 100644 index 0000000000000000000000000000000000000000..cc9412605c5d89dd392de1c4c6aee8a0452c52d3 GIT binary patch literal 8532 zcmdUVXHZjX+wMvT5PImLN$4mg2{lAIp(sT`1QY~92u(^LbSXh;N|Q~Orr1ys!d8(^ zFbFD5M1f7wAV^Vq5tR1fe)rziH>wd21y8E5XnsxQGjX4*)C_4ZE zTqi7Wb^ri6T!H{7%i+Z(q|)o~!bY+c?TP=G4l zGsuIe8W})3L<4}XK_m%JxJV2|co4mP1NEero7$uizMgv0j+)jeYmy1k$JZh{gm@;} z#-0#;k)Y!#ZJ>|Pjl>=j1Q0{Jp^Q*NsiBc54J2Aa1%<+@>tHoB5PyB757mWu zdSUHwW`8L=ywj8R2@NG-k;sUM2-OI6)u0e>Bw9yD2Z>Tcs;Q|QB2>sxfuZPa7(`Y#^>NdM3VlK+a+VZ@M;coGt=iu&c#pFmH- zKR8lYi2t9;JqbvnKQVw97)n0GqW{5?e1bxQ$UZ^;2kL*e{}%;^v9-4TN5_A(B_QA* z735IU@IyEL3dny%lkKBOM5G;&926EpAex3BnknAb{@x+JX|8F=?0@f=iBmjTtqi+D-n}{R@dP^hzi5%7>$Ui9LP~D+9>i;f3 zVPbMRB*@Fx|8RqBXKsu*VQQj<*3r^ZQBy_#X{5C^_Cz2#6dy<+p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dY_>;q+YUq ztVBsyV_jG%d2HN~x_t+7GmUL945VnVTf}`(@|?X6T!&aV_x1+Uz}VB`BW2#Cl;hg` z_j2R2g5zt$B5muw9s?dYGIe@{$GP|2<8~(a`}Y~>^w1)87CEwTw;GiXVv~Zt*-->!;v^m zWubDTlBgF(I&_C0J$-!xE|CW958=gMs+xs9`+0^IlkyF{L_f!_%#!a(ecM}5pMw0o zus;W=f|DH^1S_iTV^t`yiZlx#u@cP(Ncp8h3{ypAK(LC=|7oHFo@sLUt#tg7&ad|# NPMF%@s*T+*{}(kXk&^%b literal 0 HcmV?d00001 diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/Oracle.svelte b/packages/builder/src/components/backend/DatasourceNavigator/icons/Oracle.svelte new file mode 100644 index 0000000000..c939a59d90 --- /dev/null +++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/Oracle.svelte @@ -0,0 +1,16 @@ + + +
+ oracle logo +
+ + diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js index e251595934..56ae03dcc3 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js +++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js @@ -10,6 +10,7 @@ import MySQL from "./MySQL.svelte" import ArangoDB from "./ArangoDB.svelte" import Rest from "./Rest.svelte" import Budibase from "./Budibase.svelte" +import Oracle from "./Oracle.svelte" export default { BUDIBASE: Budibase, @@ -24,4 +25,5 @@ export default { MYSQL: MySQL, ARANGODB: ArangoDB, REST: Rest, + ORACLE: Oracle, } diff --git a/packages/builder/src/constants/index.js b/packages/builder/src/constants/index.js index c0d283b0ea..33b55228bd 100644 --- a/packages/builder/src/constants/index.js +++ b/packages/builder/src/constants/index.js @@ -27,6 +27,7 @@ export const IntegrationNames = { SQL_SERVER: "SQL Server", AIRTABLE: "Airtable", ARANGODB: "ArangoDB", + ORACLE: "Oracle", } // fields on the user table that cannot be edited diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index 2603d08b86..a16c457654 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -2,26 +2,16 @@ import { Integration, DatasourceFieldTypes, QueryTypes, - QueryJson, SqlQuery, } from "../definitions/datasource" import { Table } from "../definitions/common" import { getSqlQuery } from "./utils" -import { DatasourcePlus } from "./base/datasourcePlus" -import oracledb, { Result } from "oracledb" -import { Connection } from "oracledb" +import oracledb, { ExecuteOptions, Result } from "oracledb" +import { Connection, ConnectionAttributes } from "oracledb" import Sql from "./base/sql" -import { FieldTypes } from "../constants" -import { - buildExternalTableId, - convertType, - finaliseExternalTables -} from "./utils" - module OracleModule { oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT; - interface OracleConfig { host: string port: number @@ -34,10 +24,9 @@ module OracleModule { } const SCHEMA: Integration = { - docs: "https://docs", - // plus: true, + docs: "https://github.com/oracle/node-oracledb", friendlyName: "Oracle", - description: "description", + description: "Oracle Database is an object-relational database management system developed by Oracle Corporation", datasource: { host: { type: DatasourceFieldTypes.STRING, @@ -92,37 +81,8 @@ module OracleModule { }, }, } - - const TYPE_MAP = { - // TODO: type map - } - - const internalQuery = async (connection: Connection, query: SqlQuery): Promise | null>=> { - try { - const result: Result = await connection.execute( - `SELECT manager_id, department_id, department_name - FROM departments - WHERE manager_id = :id`, - [103], // bind value for :id - ); - return result - } catch (err) { - console.error(err); - return null - } finally { - if (connection) { - try { - await connection.close(); - } catch (err) { - console.error(err); - } - } - } - } - - class OracleIntegration extends Sql implements DatasourcePlus { + class OracleIntegration extends Sql { private readonly config: OracleConfig - private readonly client: any public tables: Record = {} public schemaErrors: Record = {} @@ -131,76 +91,55 @@ module OracleModule { this.config = config } - getConnection = async (): Promise => { + private query = async (query: SqlQuery): Promise> => { + let connection + try { + connection = await this.getConnection() + + const options : ExecuteOptions = { autoCommit: true } + const result: Result = await connection.execute(query.sql, [], options) + + return result + } finally { + if (connection) { + try { + await connection.close(); + } catch (err) { + console.error(err); + } + } + } + } + + private getConnection = async (): Promise => { //connectString : "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SID= ORCL)))" const connectString = `${this.config.host}:${this.config.port || 1521}/${this.config.database}` - const config = { + const attributes: ConnectionAttributes = { user: this.config.user, password: this.config.user, - connectString + connectString, } - return oracledb.getConnection(config); + return oracledb.getConnection(attributes); } - /** - * Fetches the tables from the postgres table and assigns them to the datasource. - * @param {*} datasourceId - datasourceId to fetch - * @param entities - the tables that are to be built - */ - async buildSchema(datasourceId: string, entities: Record) { - // get the tables - const tables: { [key: string]: Table } = {} - - // get the base table data - // { - // _id: buildExternalTableId(datasourceId, tableName), - // primary: tableKeys[tableName] || [], - // name: tableName, - // schema: {}, - // } - - // get the schema - // { - // autocolumn: isAuto, - // name: columnName, - // type, - // } - - const final = finaliseExternalTables(tables, entities) - this.tables = final.tables - this.schemaErrors = final.errors + async create(query: SqlQuery | string) { + const response = await this.query(getSqlQuery(query)) + return response.rows && response.rows.length ? response.rows : [{ created: true }] } - // async create(query: SqlQuery | string) { - // const response = await internalQuery(this.client, getSqlQuery(query)) - // return response.rows.length ? response.rows : [{ created: true }] - // } + async read(query: SqlQuery | string) { + const response = await this.query(getSqlQuery(query)) + return response.rows + } - // async read(query: SqlQuery | string) { - // const response = await internalQuery(this.client, getSqlQuery(query)) - // return response.rows - // } + async update(query: SqlQuery | string) { + const response = await this.query(getSqlQuery(query)) + return response.rows && response.rows.length ? response.rows : [{ updated: true }] + } - // async update(query: SqlQuery | string) { - // const response = await internalQuery(this.client, getSqlQuery(query)) - // return response.rows.length ? response.rows : [{ updated: true }] - // } - - // async delete(query: SqlQuery | string) { - // const response = await internalQuery(this.client, getSqlQuery(query)) - // return response.rows.length ? response.rows : [{ deleted: true }] - // } - - async query(json: QueryJson) { - const operation = this._operation(json).toLowerCase() - const input = this._query(json) - const connection = await this.getConnection() - const result = await internalQuery(connection, input) - if (result && result.rows && result.rows.length) { - return result.rows - } else { - return [{ [operation]: true }] - } + async delete(query: SqlQuery | string) { + const response = await this.query(getSqlQuery(query)) + return response.rows && response.rows.length ? response.rows : [{ deleted: true }] } }