diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/ArangoDB.svelte b/packages/builder/src/components/backend/DatasourceNavigator/icons/ArangoDB.svelte new file mode 100644 index 0000000000..0be4ca2663 --- /dev/null +++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/ArangoDB.svelte @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js index 4f8d79dbf4..ff38782288 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js +++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js @@ -7,6 +7,7 @@ import S3 from "./S3.svelte" import Airtable from "./Airtable.svelte" import SqlServer from "./SQLServer.svelte" import MySQL from "./MySQL.svelte" +import ArangoDB from "./ArangoDB.svelte" export default { POSTGRES: Postgres, @@ -18,4 +19,5 @@ export default { S3: S3, AIRTABLE: Airtable, MYSQL: MySQL, + ARANGODB: ArangoDB, } diff --git a/packages/server/package.json b/packages/server/package.json index fd8d5196a0..2ee2c79e22 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -56,6 +56,7 @@ "@sendgrid/mail": "^7.1.1", "@sentry/node": "^5.19.2", "airtable": "^0.10.1", + "arangojs": "^7.2.0", "aws-sdk": "^2.767.0", "bcryptjs": "^2.4.3", "chmodr": "^1.2.0", diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js new file mode 100644 index 0000000000..10449fc967 --- /dev/null +++ b/packages/server/src/integrations/arangodb.js @@ -0,0 +1,83 @@ +const { Database, aql } = require("arangojs") +const { FIELD_TYPES, QUERY_TYPES } = require("./Integration") + +const SCHEMA = { + docs: "https://github.com/arangodb/arangojs", + datasource: { + url: { + type: FIELD_TYPES.STRING, + default: "http://localhost:8529", + required: true, + }, + username: { + type: FIELD_TYPES.STRING, + default: "root", + required: true, + }, + password: { + type: FIELD_TYPES.PASSWORD, + required: true, + }, + databaseName: { + type: FIELD_TYPES.STRING, + default: "_system", + required: true, + }, + collection: { + type: FIELD_TYPES.STRING, + required: true, + }, + }, + query: { + read: { + type: QUERY_TYPES.SQL, + }, + create: { + type: QUERY_TYPES.JSON, + }, + }, +} + +class ArangoDBIntegration { + constructor(config) { + config.auth = { + username: config.username, + password: config.password, + } + + this.config = config + this.client = new Database(config) + } + + async read(query) { + try { + const result = await this.client.query(query.sql) + return result.all() + } catch (err) { + console.error("Error querying arangodb", err.message) + throw err + } finally { + this.client.close() + } + } + + async create(query) { + const clc = this.client.collection(this.config.collection) + try { + const result = await this.client.query( + aql`INSERT ${query.json} INTO ${clc} RETURN NEW` + ) + return result.all() + } catch (err) { + console.error("Error querying arangodb", err.message) + throw err + } finally { + this.client.close() + } + } +} + +module.exports = { + schema: SCHEMA, + integration: ArangoDBIntegration, +} diff --git a/packages/server/src/integrations/index.js b/packages/server/src/integrations/index.js index acb81992a9..9f9d5a1530 100644 --- a/packages/server/src/integrations/index.js +++ b/packages/server/src/integrations/index.js @@ -7,6 +7,7 @@ const sqlServer = require("./microsoftSqlServer") const s3 = require("./s3") const airtable = require("./airtable") const mysql = require("./mysql") +const arangodb = require("./arangodb") const DEFINITIONS = { POSTGRES: postgres.schema, @@ -18,6 +19,7 @@ const DEFINITIONS = { S3: s3.schema, AIRTABLE: airtable.schema, MYSQL: mysql.schema, + ARANGODB: arangodb.schema, } const INTEGRATIONS = { @@ -30,6 +32,7 @@ const INTEGRATIONS = { SQL_SERVER: sqlServer.integration, AIRTABLE: airtable.integration, MYSQL: mysql.integration, + ARANGODB: arangodb.integration, } module.exports = {