Some quick fixes to allow custom verbs.
This commit is contained in:
parent
32c2a78148
commit
ec21fcbc4d
|
@ -119,6 +119,16 @@ export const getBackendUiStore = () => {
|
|||
return json
|
||||
},
|
||||
save: async (datasourceId, query) => {
|
||||
const integrations = get(store).integrations
|
||||
const dataSource = get(store).datasources.filter(ds => ds._id === datasourceId)
|
||||
// check if readable attribute is found
|
||||
if (dataSource.length !== 0) {
|
||||
const integration = integrations[dataSource[0].source]
|
||||
const readable = integration.query[query.queryVerb].readable
|
||||
if (readable) {
|
||||
query.readable = readable
|
||||
}
|
||||
}
|
||||
query.datasourceId = datasourceId
|
||||
const response = await api.post(`/api/queries`, query)
|
||||
const json = await response.json()
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
return [...acc, ...viewsArr]
|
||||
}, [])
|
||||
$: queries = $backendUiStore.queries
|
||||
.filter(query => query.queryVerb === "read")
|
||||
.filter(query => query.queryVerb === "read" || query.readable)
|
||||
.map(query => ({
|
||||
label: query.name,
|
||||
name: query.name,
|
||||
|
|
|
@ -26,6 +26,7 @@ function generateQueryValidation() {
|
|||
name: Joi.string().required(),
|
||||
fields: Joi.object().required(),
|
||||
datasourceId: Joi.string().required(),
|
||||
readable: Joi.boolean(),
|
||||
parameters: Joi.array().items(Joi.object({
|
||||
name: Joi.string(),
|
||||
default: Joi.string()
|
||||
|
|
|
@ -37,6 +37,7 @@ const SCHEMA = {
|
|||
read: {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
customisable: true,
|
||||
readable: true,
|
||||
fields: {
|
||||
table: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
|
@ -50,6 +51,7 @@ const SCHEMA = {
|
|||
scan: {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
customisable: true,
|
||||
readable: true,
|
||||
fields: {
|
||||
table: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
|
@ -63,6 +65,7 @@ const SCHEMA = {
|
|||
get: {
|
||||
type: QUERY_TYPES.FIELDS,
|
||||
customisable: true,
|
||||
readable: true,
|
||||
fields: {
|
||||
table: {
|
||||
type: FIELD_TYPES.STRING,
|
||||
|
|
|
@ -302,6 +302,11 @@ describe("Cover a few complex use cases", () => {
|
|||
expect(validity).toBe(true)
|
||||
})
|
||||
|
||||
it("should make sure object functions check out valid", () => {
|
||||
const validity = isValid("{{ JSONstringify obj }}")
|
||||
expect(validity).toBe(true)
|
||||
})
|
||||
|
||||
it("should be able to solve an example from docs", async () => {
|
||||
const output = await processString(`{{first ( split "a-b-c" "-") 2}}`, {})
|
||||
expect(output).toBe(`a,b`)
|
||||
|
|
Loading…
Reference in New Issue