diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 0a235dd9a0..ef2b3ac60b 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -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() diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte index 5031b37323..a467a954a2 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/TableViewSelect.svelte @@ -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, diff --git a/packages/server/src/api/routes/query.js b/packages/server/src/api/routes/query.js index ae5e6bc317..8a84138af5 100644 --- a/packages/server/src/api/routes/query.js +++ b/packages/server/src/api/routes/query.js @@ -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() diff --git a/packages/server/src/integrations/dynamodb.js b/packages/server/src/integrations/dynamodb.js index 85beabc058..6f3c5787ba 100644 --- a/packages/server/src/integrations/dynamodb.js +++ b/packages/server/src/integrations/dynamodb.js @@ -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, diff --git a/packages/string-templates/test/helpers.spec.js b/packages/string-templates/test/helpers.spec.js index a602b286e4..7aaf6bf466 100644 --- a/packages/string-templates/test/helpers.spec.js +++ b/packages/string-templates/test/helpers.spec.js @@ -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`)