From 7ed062bf1e7c75ba68b972af86486e2c7453400d Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 15 Jan 2021 17:29:46 +0000 Subject: [PATCH] fix no schema bug, feedback from demo --- .../src/components/integration/QueryViewer.svelte | 13 ++++++++++--- packages/server/src/integrations/airtable.js | 1 + packages/server/src/integrations/couchdb.js | 1 + packages/server/src/integrations/dynamodb.js | 1 + packages/server/src/integrations/elasticsearch.js | 2 ++ .../server/src/integrations/microsoftSqlServer.js | 1 + packages/server/src/integrations/mongodb.js | 1 + packages/server/src/integrations/postgres.js | 1 + packages/server/src/integrations/s3.js | 1 + 9 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/integration/QueryViewer.svelte b/packages/builder/src/components/integration/QueryViewer.svelte index 641f3a64c1..6d3d984962 100644 --- a/packages/builder/src/components/integration/QueryViewer.svelte +++ b/packages/builder/src/components/integration/QueryViewer.svelte @@ -39,7 +39,7 @@ let config let tab = "JSON" let parameters - let data + let data = [] $: datasource = $backendUiStore.datasources.find( ds => ds._id === query.datasourceId @@ -91,13 +91,20 @@ data = json || [] + + if (data.length === 0) { + notifier.info("Query results empty. Please execute a query with results to create your schema.") + return + } + + notifier.success("Query executed successfully.") + // Assume all the fields are strings and create a basic schema // from the first record returned by the query fields = Object.keys(json[0]).map(field => ({ name: field, type: "STRING", })) - notifier.success("Query executed successfully.") } catch (err) { notifier.danger(`Query Error: ${err.message}`) console.error(err) @@ -163,7 +170,7 @@
- diff --git a/packages/server/src/integrations/airtable.js b/packages/server/src/integrations/airtable.js index cb085f823c..cd72c5e3e2 100644 --- a/packages/server/src/integrations/airtable.js +++ b/packages/server/src/integrations/airtable.js @@ -2,6 +2,7 @@ const Airtable = require("airtable") const { FIELD_TYPES, QUERY_TYPES } = require("./Integration") const SCHEMA = { + docs: "https://airtable.com/api", datasource: { apiKey: { type: FIELD_TYPES.STRING, diff --git a/packages/server/src/integrations/couchdb.js b/packages/server/src/integrations/couchdb.js index c6474ff2b5..bf2a009027 100644 --- a/packages/server/src/integrations/couchdb.js +++ b/packages/server/src/integrations/couchdb.js @@ -2,6 +2,7 @@ const PouchDB = require("pouchdb") const { FIELD_TYPES, QUERY_TYPES } = require("./Integration") const SCHEMA = { + docs: "https://docs.couchdb.org/en/stable/", datasource: { url: { type: FIELD_TYPES.STRING, diff --git a/packages/server/src/integrations/dynamodb.js b/packages/server/src/integrations/dynamodb.js index b1c406fdf4..026d791b1f 100644 --- a/packages/server/src/integrations/dynamodb.js +++ b/packages/server/src/integrations/dynamodb.js @@ -2,6 +2,7 @@ const AWS = require("aws-sdk") const { FIELD_TYPES, QUERY_TYPES } = require("./Integration") const SCHEMA = { + docs: "https://github.com/dabit3/dynamodb-documentclient-cheat-sheet", datasource: { region: { type: FIELD_TYPES.STRING, diff --git a/packages/server/src/integrations/elasticsearch.js b/packages/server/src/integrations/elasticsearch.js index 817cb43696..e8637f7c32 100644 --- a/packages/server/src/integrations/elasticsearch.js +++ b/packages/server/src/integrations/elasticsearch.js @@ -2,6 +2,8 @@ const { Client } = require("@elastic/elasticsearch") const { QUERY_TYPES, FIELD_TYPES } = require("./Integration") const SCHEMA = { + docs: + "https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", datasource: { url: { type: "string", diff --git a/packages/server/src/integrations/microsoftSqlServer.js b/packages/server/src/integrations/microsoftSqlServer.js index cabf70c2bf..7431465065 100644 --- a/packages/server/src/integrations/microsoftSqlServer.js +++ b/packages/server/src/integrations/microsoftSqlServer.js @@ -2,6 +2,7 @@ const sqlServer = require("mssql") const { FIELD_TYPES } = require("./Integration") const SCHEMA = { + docs: "https://github.com/tediousjs/node-mssql", datasource: { user: { type: FIELD_TYPES.STRING, diff --git a/packages/server/src/integrations/mongodb.js b/packages/server/src/integrations/mongodb.js index b0ccb2d78a..96457d5c2f 100644 --- a/packages/server/src/integrations/mongodb.js +++ b/packages/server/src/integrations/mongodb.js @@ -2,6 +2,7 @@ const { MongoClient } = require("mongodb") const { FIELD_TYPES, QUERY_TYPES } = require("./Integration") const SCHEMA = { + docs: "https://github.com/mongodb/node-mongodb-native", datasource: { connectionString: { type: FIELD_TYPES.STRING, diff --git a/packages/server/src/integrations/postgres.js b/packages/server/src/integrations/postgres.js index d6e5041003..cd87e20a64 100644 --- a/packages/server/src/integrations/postgres.js +++ b/packages/server/src/integrations/postgres.js @@ -1,6 +1,7 @@ const { Client } = require("pg") const SCHEMA = { + docs: "https://node-postgres.com", datasource: { host: { type: "string", diff --git a/packages/server/src/integrations/s3.js b/packages/server/src/integrations/s3.js index e01c45227d..30a204a175 100644 --- a/packages/server/src/integrations/s3.js +++ b/packages/server/src/integrations/s3.js @@ -1,6 +1,7 @@ const AWS = require("aws-sdk") const SCHEMA = { + docs: "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html", datasource: { region: { type: "string",