1
0
Fork 0
mirror of synced 2024-07-30 02:26:11 +12:00

Base connection work - extending the base integration to include the option of a connection check function.

This commit is contained in:
mike12345567 2023-05-05 15:47:55 +01:00
parent c880282be3
commit ce6c5bfa68
16 changed files with 66 additions and 5 deletions

View file

@ -1,8 +1,9 @@
import {
Integration,
DatasourceFeature,
DatasourceFieldType,
QueryType,
Integration,
IntegrationBase,
QueryType,
} from "@budibase/types"
const Airtable = require("airtable")
@ -18,6 +19,7 @@ const SCHEMA: Integration = {
"Airtable is a spreadsheet-database hybrid, with the features of a database but applied to a spreadsheet.",
friendlyName: "Airtable",
type: "Spreadsheet",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
apiKey: {
type: DatasourceFieldType.PASSWORD,
@ -88,6 +90,10 @@ class AirtableIntegration implements IntegrationBase {
this.client = new Airtable(config).base(config.base)
}
async connection() {
return { connected: true }
}
async create(query: { table: any; json: any }) {
const { table, json } = query

View file

@ -3,6 +3,7 @@ import {
DatasourceFieldType,
QueryType,
IntegrationBase,
DatasourceFeature,
} from "@budibase/types"
const { Database, aql } = require("arangojs")
@ -21,6 +22,7 @@ const SCHEMA: Integration = {
type: "Non-relational",
description:
"ArangoDB is a scalable open-source multi-model database natively supporting graph, document and search. All supported data models & access patterns can be combined in queries allowing for maximal flexibility. ",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
url: {
type: DatasourceFieldType.STRING,
@ -74,6 +76,10 @@ class ArangoDBIntegration implements IntegrationBase {
this.client = new Database(newConfig)
}
async connection() {
return { connected: true }
}
async read(query: { sql: any }) {
try {
const result = await this.client.query(query.sql)

View file

@ -1,4 +1,5 @@
import {
DatasourceFeature,
DatasourceFieldType,
Document,
Integration,
@ -18,6 +19,7 @@ const SCHEMA: Integration = {
type: "Non-relational",
description:
"Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
url: {
type: DatasourceFieldType.STRING,
@ -69,6 +71,10 @@ class CouchDBIntegration implements IntegrationBase {
this.client = dbCore.DatabaseWithConnection(config.database, config.url)
}
async connection() {
return { connected: true }
}
async query(
command: string,
errorMsg: string,

View file

@ -3,6 +3,7 @@ import {
DatasourceFieldType,
QueryType,
IntegrationBase,
DatasourceFeature,
} from "@budibase/types"
import AWS from "aws-sdk"
@ -22,6 +23,7 @@ const SCHEMA: Integration = {
"Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale.",
friendlyName: "DynamoDB",
type: "Non-relational",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
region: {
type: DatasourceFieldType.STRING,

View file

@ -3,6 +3,7 @@ import {
DatasourceFieldType,
QueryType,
IntegrationBase,
DatasourceFeature,
} from "@budibase/types"
import { Client, ClientOptions } from "@elastic/elasticsearch"
@ -20,6 +21,7 @@ const SCHEMA: Integration = {
"Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.",
friendlyName: "ElasticSearch",
type: "Non-relational",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
url: {
type: DatasourceFieldType.STRING,

View file

@ -3,6 +3,7 @@ import {
Integration,
QueryType,
IntegrationBase,
DatasourceFeature,
} from "@budibase/types"
import { Firestore, WhereFilterOp } from "@google-cloud/firestore"
@ -18,6 +19,7 @@ const SCHEMA: Integration = {
type: "Non-relational",
description:
"Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
email: {
type: DatasourceFieldType.STRING,

View file

@ -1,4 +1,5 @@
import {
DatasourceFeature,
DatasourceFieldType,
DatasourcePlus,
FieldType,
@ -64,6 +65,7 @@ const SCHEMA: Integration = {
"Create and collaborate on online spreadsheets in real-time and from any device. ",
friendlyName: "Google Sheets",
type: "Spreadsheet",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
spreadsheetId: {
display: "Google Sheet URL",

View file

@ -8,6 +8,7 @@ import {
QueryType,
SqlQuery,
DatasourcePlus,
DatasourceFeature,
} from "@budibase/types"
import {
getSqlQuery,
@ -39,6 +40,7 @@ const SCHEMA: Integration = {
"Microsoft SQL Server is a relational database management system developed by Microsoft. ",
friendlyName: "MS SQL Server",
type: "Relational",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
user: {
type: DatasourceFieldType.STRING,

View file

@ -3,6 +3,7 @@ import {
DatasourceFieldType,
QueryType,
IntegrationBase,
DatasourceFeature,
} from "@budibase/types"
import {
MongoClient,
@ -38,6 +39,7 @@ const getSchema = () => {
type: "Non-relational",
description:
"MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
connectionString: {
type: DatasourceFieldType.STRING,

View file

@ -7,6 +7,7 @@ import {
Table,
TableSchema,
DatasourcePlus,
DatasourceFeature,
} from "@budibase/types"
import {
getSqlQuery,
@ -41,6 +42,7 @@ const SCHEMA: Integration = {
type: "Relational",
description:
"MySQL Database Service is a fully managed database service to deploy cloud-native applications. ",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
host: {
type: DatasourceFieldType.STRING,

View file

@ -7,6 +7,7 @@ import {
SqlQuery,
Table,
DatasourcePlus,
DatasourceFeature,
} from "@budibase/types"
import {
buildExternalTableId,
@ -53,6 +54,7 @@ const SCHEMA: Integration = {
type: "Relational",
description:
"Oracle Database is an object-relational database management system developed by Oracle Corporation",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
host: {
type: DatasourceFieldType.STRING,

View file

@ -6,6 +6,7 @@ import {
SqlQuery,
Table,
DatasourcePlus,
DatasourceFeature,
} from "@budibase/types"
import {
getSqlQuery,
@ -50,6 +51,7 @@ const SCHEMA: Integration = {
type: "Relational",
description:
"PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
host: {
type: DatasourceFieldType.STRING,

View file

@ -1,4 +1,9 @@
import { DatasourceFieldType, Integration, QueryType } from "@budibase/types"
import {
DatasourceFeature,
DatasourceFieldType,
Integration,
QueryType,
} from "@budibase/types"
import Redis from "ioredis"
interface RedisConfig {
@ -11,9 +16,11 @@ interface RedisConfig {
const SCHEMA: Integration = {
docs: "https://redis.io/docs/",
description: "",
description:
"Redis is a caching tool, providing powerful key-value store capabilities.",
friendlyName: "Redis",
type: "Non-relational",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
host: {
type: "string",

View file

@ -3,6 +3,7 @@ import {
QueryType,
IntegrationBase,
DatasourceFieldType,
DatasourceFeature,
} from "@budibase/types"
const AWS = require("aws-sdk")
@ -22,6 +23,7 @@ const SCHEMA: Integration = {
"Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.",
friendlyName: "Amazon S3",
type: "Object store",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
region: {
type: "string",

View file

@ -1,4 +1,9 @@
import { Integration, QueryType, SqlQuery } from "@budibase/types"
import {
DatasourceFeature,
Integration,
QueryType,
SqlQuery,
} from "@budibase/types"
import { Snowflake } from "snowflake-promise"
interface SnowflakeConfig {
@ -16,6 +21,7 @@ const SCHEMA: Integration = {
"Snowflake is a solution for data warehousing, data lakes, data engineering, data science, data application development, and securely sharing and consuming shared data.",
friendlyName: "Snowflake",
type: "Relational",
features: [DatasourceFeature.CONNECTION_CHECKING],
datasource: {
account: {
type: "string",

View file

@ -74,6 +74,10 @@ export enum FilterType {
ONE_OF = "oneOf",
}
export enum DatasourceFeature {
CONNECTION_CHECKING = "connection",
}
export interface StepDefinition {
key: string
template: string
@ -112,6 +116,7 @@ export interface Integration {
docs: string
plus?: boolean
auth?: { type: string }
features?: DatasourceFeature[]
relationships?: boolean
description: string
friendlyName: string
@ -124,11 +129,16 @@ export interface Integration {
extra?: ExtraQueryConfig
}
export interface ConnectionInformation {
connected: boolean
}
export interface IntegrationBase {
create?(query: any): Promise<any[] | any>
read?(query: any): Promise<any[] | any>
update?(query: any): Promise<any[] | any>
delete?(query: any): Promise<any[] | any>
connection?(): Promise<ConnectionInformation>
}
export interface DatasourcePlus extends IntegrationBase {