simplify queries to only have one type under query verb

This commit is contained in:
Martin McKeaveney 2021-01-22 12:22:28 +00:00
parent 46a04bbf9d
commit 476d20d656
15 changed files with 110 additions and 170 deletions

View File

@ -63,7 +63,7 @@
$: config = $backendUiStore.integrations[datasourceType]?.query $: config = $backendUiStore.integrations[datasourceType]?.query
$: docsLink = $backendUiStore.integrations[datasourceType]?.docs $: docsLink = $backendUiStore.integrations[datasourceType]?.docs
$: shouldShowQueryConfig = config && query.queryVerb && query.queryType $: shouldShowQueryConfig = config && query.queryVerb
function newField() { function newField() {
fields = [...fields, {}] fields = [...fields, {}]
@ -140,12 +140,9 @@
<option value={queryVerb}>{queryVerb}</option> <option value={queryVerb}>{queryVerb}</option>
{/each} {/each}
</Select> </Select>
<Select thin secondary bind:value={query.queryType}> <div>
<option value={""}>Please select an option</option> {config[query.queryVerb].type}
{#each Object.keys(config[query.queryVerb]) as queryType} </div>
<option value={queryType}>{queryType}</option>
{/each}
</Select>
<EditQueryParamsPopover bind:parameters={query.parameters} bindable={false} /> <EditQueryParamsPopover bind:parameters={query.parameters} bindable={false} />
<Spacer medium /> <Spacer medium />
<Button primary href={docsLink} target="_blank"> <Button primary href={docsLink} target="_blank">
@ -166,7 +163,7 @@
<IntegrationQueryEditor <IntegrationQueryEditor
{query} {query}
schema={config[query.queryVerb][query.queryType]} schema={config[query.queryVerb]}
bind:parameters /> bind:parameters />
<Spacer medium /> <Spacer medium />

View File

@ -76,9 +76,7 @@
const source = $backendUiStore.datasources.find( const source = $backendUiStore.datasources.find(
ds => ds._id === query.datasourceId ds => ds._id === query.datasourceId
).source ).source
return $backendUiStore.integrations[source].query[query.queryVerb][ return $backendUiStore.integrations[source].query[query.queryVerb]
query.queryType
]
} }
</script> </script>

View File

@ -25,7 +25,6 @@
parameters: [], parameters: [],
fields: {}, fields: {},
queryVerb: "read", queryVerb: "read",
queryType: "",
} }
</script> </script>

View File

@ -51,7 +51,6 @@
<div class="query-list-item" on:click={() => onClickQuery(query)}> <div class="query-list-item" on:click={() => onClickQuery(query)}>
<p class="query-name">{query.name}</p> <p class="query-name">{query.name}</p>
<p>{query.queryVerb}</p> <p>{query.queryVerb}</p>
<p>{query.queryType}</p>
<p>4000 records</p> <p>4000 records</p>
<p></p> <p></p>
</div> </div>

View File

@ -31,7 +31,6 @@ function generateQueryValidation() {
default: Joi.string() default: Joi.string()
})), })),
queryVerb: Joi.string().allow(...Object.values(QueryVerb)).required(), queryVerb: Joi.string().allow(...Object.values(QueryVerb)).required(),
queryType: Joi.string().required(),
schema: Joi.object({}).required().unknown(true) schema: Joi.object({}).required().unknown(true)
})) }))
} }

View File

@ -26,7 +26,6 @@ const TEST_QUERY = {
fields:{}, fields:{},
schema:{}, schema:{},
queryVerb:"read", queryVerb:"read",
queryType:"Table",
} }
describe("/datasources", () => { describe("/datasources", () => {

View File

@ -26,7 +26,6 @@ const TEST_QUERY = {
fields:{}, fields:{},
schema:{}, schema:{},
queryVerb:"read", queryVerb:"read",
queryType:"Table",
} }
describe("/queries", () => { describe("/queries", () => {

View File

@ -17,7 +17,6 @@ const SCHEMA = {
}, },
query: { query: {
create: { create: {
"Airtable Record": {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
customisable: true, customisable: true,
fields: { fields: {
@ -27,9 +26,7 @@ const SCHEMA = {
}, },
}, },
}, },
},
read: { read: {
Table: {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
fields: { fields: {
table: { table: {
@ -42,9 +39,7 @@ const SCHEMA = {
}, },
}, },
}, },
},
update: { update: {
Fields: {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
customisable: true, customisable: true,
fields: { fields: {
@ -54,13 +49,10 @@ const SCHEMA = {
}, },
}, },
}, },
},
delete: { delete: {
"Airtable Ids": {
type: FIELD_TYPES.JSON, type: FIELD_TYPES.JSON,
}, },
}, },
},
} }
class AirtableIntegration { class AirtableIntegration {

View File

@ -16,22 +16,15 @@ const SCHEMA = {
}, },
query: { query: {
create: { create: {
"CouchDB DSL": {
type: QUERY_TYPES.JSON, type: QUERY_TYPES.JSON,
}, },
},
read: { read: {
"CouchDB DSL": {
type: QUERY_TYPES.JSON, type: QUERY_TYPES.JSON,
}, },
},
update: { update: {
"CouchDB Document": {
type: QUERY_TYPES.JSON, type: QUERY_TYPES.JSON,
}, },
},
delete: { delete: {
"Document ID": {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
fields: { fields: {
id: { id: {
@ -41,7 +34,6 @@ const SCHEMA = {
}, },
}, },
}, },
},
} }
class CouchDBIntegration { class CouchDBIntegration {

View File

@ -20,7 +20,6 @@ const SCHEMA = {
}, },
query: { query: {
create: { create: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
fields: { fields: {
table: { table: {
@ -30,9 +29,7 @@ const SCHEMA = {
customisable: true, customisable: true,
}, },
}, },
},
read: { read: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
fields: { fields: {
table: { table: {
@ -45,9 +42,7 @@ const SCHEMA = {
customisable: true, customisable: true,
}, },
}, },
},
update: { update: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
fields: { fields: {
table: { table: {
@ -57,9 +52,7 @@ const SCHEMA = {
customisable: true, customisable: true,
}, },
}, },
},
delete: { delete: {
"Dynamo Partition Key": {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
fields: { fields: {
table: { table: {
@ -73,7 +66,6 @@ const SCHEMA = {
}, },
}, },
}, },
},
} }
class DynamoDBIntegration { class DynamoDBIntegration {

View File

@ -13,7 +13,6 @@ const SCHEMA = {
}, },
query: { query: {
create: { create: {
"ES Query DSL": {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
customisable: true, customisable: true,
fields: { fields: {
@ -23,9 +22,7 @@ const SCHEMA = {
}, },
}, },
}, },
},
read: { read: {
"ES Query DSL": {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
customisable: true, customisable: true,
fields: { fields: {
@ -35,9 +32,7 @@ const SCHEMA = {
}, },
}, },
}, },
},
update: { update: {
"ES Query DSL": {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
customisable: true, customisable: true,
fields: { fields: {
@ -51,9 +46,7 @@ const SCHEMA = {
}, },
}, },
}, },
},
delete: { delete: {
"Document ID": {
type: QUERY_TYPES.FIELDS, type: QUERY_TYPES.FIELDS,
fields: { fields: {
index: { index: {
@ -67,7 +60,6 @@ const SCHEMA = {
}, },
}, },
}, },
},
} }
class ElasticSearchIntegration { class ElasticSearchIntegration {

View File

@ -24,16 +24,12 @@ const SCHEMA = {
}, },
query: { query: {
create: { create: {
SQL: {
type: "sql", type: "sql",
}, },
},
read: { read: {
SQL: {
type: "sql", type: "sql",
}, },
}, },
},
} }
class SqlServerIntegration { class SqlServerIntegration {

View File

@ -20,16 +20,12 @@ const SCHEMA = {
}, },
query: { query: {
create: { create: {
JSON: {
type: QUERY_TYPES.JSON, type: QUERY_TYPES.JSON,
}, },
},
read: { read: {
JSON: {
type: QUERY_TYPES.JSON, type: QUERY_TYPES.JSON,
}, },
}, },
},
} }
class MongoIntegration { class MongoIntegration {

View File

@ -31,26 +31,18 @@ const SCHEMA = {
}, },
query: { query: {
create: { create: {
SQL: {
type: "sql", type: "sql",
}, },
},
read: { read: {
SQL: {
type: "sql", type: "sql",
}, },
},
update: { update: {
SQL: {
type: "sql", type: "sql",
}, },
},
delete: { delete: {
SQL: {
type: "sql", type: "sql",
}, },
}, },
},
} }
class PostgresIntegration { class PostgresIntegration {

View File

@ -19,7 +19,6 @@ const SCHEMA = {
}, },
query: { query: {
read: { read: {
Bucket: {
type: "fields", type: "fields",
fields: { fields: {
bucket: { bucket: {
@ -29,7 +28,6 @@ const SCHEMA = {
}, },
}, },
}, },
},
} }
class S3Integration { class S3Integration {