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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,48 +17,40 @@ const SCHEMA = {
},
query: {
create: {
"Airtable Record": {
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},
read: {
Table: {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
view: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
view: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},
update: {
Fields: {
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
id: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
id: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},
delete: {
"Airtable Ids": {
type: FIELD_TYPES.JSON,
},
type: FIELD_TYPES.JSON,
},
},
}

View File

@ -16,28 +16,20 @@ const SCHEMA = {
},
query: {
create: {
"CouchDB DSL": {
type: QUERY_TYPES.JSON,
},
type: QUERY_TYPES.JSON,
},
read: {
"CouchDB DSL": {
type: QUERY_TYPES.JSON,
},
type: QUERY_TYPES.JSON,
},
update: {
"CouchDB Document": {
type: QUERY_TYPES.JSON,
},
type: QUERY_TYPES.JSON,
},
delete: {
"Document ID": {
type: QUERY_TYPES.FIELDS,
fields: {
id: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
fields: {
id: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},

View File

@ -20,56 +20,48 @@ const SCHEMA = {
},
query: {
create: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
customisable: true,
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
customisable: true,
},
},
read: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
index: {
type: FIELD_TYPES.STRING,
},
customisable: true,
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
index: {
type: FIELD_TYPES.STRING,
},
customisable: true,
},
},
update: {
DynamoConfig: {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
customisable: true,
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
customisable: true,
},
},
delete: {
"Dynamo Partition Key": {
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
key: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
fields: {
table: {
type: FIELD_TYPES.STRING,
required: true,
},
key: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},

View File

@ -13,57 +13,49 @@ const SCHEMA = {
},
query: {
create: {
"ES Query DSL": {
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
index: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
index: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},
read: {
"ES Query DSL": {
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
index: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
index: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},
update: {
"ES Query DSL": {
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
id: {
type: FIELD_TYPES.STRING,
required: true,
},
index: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
customisable: true,
fields: {
id: {
type: FIELD_TYPES.STRING,
required: true,
},
index: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},
delete: {
"Document ID": {
type: QUERY_TYPES.FIELDS,
fields: {
index: {
type: FIELD_TYPES.STRING,
required: true,
},
id: {
type: FIELD_TYPES.STRING,
required: true,
},
type: QUERY_TYPES.FIELDS,
fields: {
index: {
type: FIELD_TYPES.STRING,
required: true,
},
id: {
type: FIELD_TYPES.STRING,
required: true,
},
},
},

View File

@ -24,14 +24,10 @@ const SCHEMA = {
},
query: {
create: {
SQL: {
type: "sql",
},
type: "sql",
},
read: {
SQL: {
type: "sql",
},
type: "sql",
},
},
}

View File

@ -20,14 +20,10 @@ const SCHEMA = {
},
query: {
create: {
JSON: {
type: QUERY_TYPES.JSON,
},
type: QUERY_TYPES.JSON,
},
read: {
JSON: {
type: QUERY_TYPES.JSON,
},
type: QUERY_TYPES.JSON,
},
},
}

View File

@ -31,24 +31,16 @@ const SCHEMA = {
},
query: {
create: {
SQL: {
type: "sql",
},
type: "sql",
},
read: {
SQL: {
type: "sql",
},
type: "sql",
},
update: {
SQL: {
type: "sql",
},
type: "sql",
},
delete: {
SQL: {
type: "sql",
},
type: "sql",
},
},
}

View File

@ -19,13 +19,11 @@ const SCHEMA = {
},
query: {
read: {
Bucket: {
type: "fields",
fields: {
bucket: {
type: "string",
required: true,
},
type: "fields",
fields: {
bucket: {
type: "string",
required: true,
},
},
},