1
0
Fork 0
mirror of synced 2024-07-03 13:30:46 +12:00

Some quick fixes to allow custom verbs.

This commit is contained in:
mike12345567 2021-02-02 17:28:11 +00:00
parent 32c2a78148
commit ec21fcbc4d
5 changed files with 20 additions and 1 deletions

View file

@ -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()

View file

@ -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,

View file

@ -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()

View file

@ -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,

View file

@ -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`)