Merge pull request #6638 from Budibase/fix/6633

July release fixes
This commit is contained in:
Michael Drury 2022-07-13 14:01:32 +01:00 committed by GitHub
commit 956cd01a3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 85 additions and 43 deletions

View File

@ -90,8 +90,8 @@ export function createQueriesStore() {
// Assume all the fields are strings and create a basic schema from the // Assume all the fields are strings and create a basic schema from the
// unique fields returned by the server // unique fields returned by the server
const schema = {} const schema = {}
for (let field of result.schemaFields) { for (let [field, type] of Object.entries(result.schemaFields)) {
schema[field] = "string" schema[field] = type || "string"
} }
return { ...result, schema, rows: result.rows || [] } return { ...result, schema, rows: result.rows || [] }
}, },

View File

@ -1,5 +1,5 @@
import { generateQueryID, getQueryParams, isProdAppID } from "../../../db/utils" import { generateQueryID, getQueryParams, isProdAppID } from "../../../db/utils"
import { BaseQueryVerbs } from "../../../constants" import { BaseQueryVerbs, FieldTypes } from "../../../constants"
import { Thread, ThreadType } from "../../../threads" import { Thread, ThreadType } from "../../../threads"
import { save as saveDatasource } from "../datasource" import { save as saveDatasource } from "../datasource"
import { RestImporter } from "./import" import { RestImporter } from "./import"
@ -154,10 +154,37 @@ export async function preview(ctx: any) {
}, },
}) })
const { rows, keys, info, extra } = await quotas.addQuery(runFn) const { rows, keys, info, extra } = await quotas.addQuery(runFn)
const schemaFields: any = {}
if (rows?.length > 0) {
for (let key of [...new Set(keys)] as string[]) {
const field = rows[0][key]
let type = typeof field,
fieldType = FieldTypes.STRING
if (field)
switch (type) {
case "boolean":
schemaFields[key] = FieldTypes.BOOLEAN
break
case "object":
if (field instanceof Date) {
fieldType = FieldTypes.DATETIME
} else if (Array.isArray(field)) {
fieldType = FieldTypes.ARRAY
} else {
fieldType = FieldTypes.JSON
}
break
case "number":
fieldType = FieldTypes.NUMBER
break
}
schemaFields[key] = fieldType
}
}
await events.query.previewed(datasource, query) await events.query.previewed(datasource, query)
ctx.body = { ctx.body = {
rows, rows,
schemaFields: [...new Set(keys)], schemaFields,
info, info,
extra, extra,
} }

View File

@ -215,7 +215,10 @@ describe("/queries", () => {
.expect("Content-Type", /json/) .expect("Content-Type", /json/)
.expect(200) .expect(200)
// these responses come from the mock // these responses come from the mock
expect(res.body.schemaFields).toEqual(["a", "b"]) expect(res.body.schemaFields).toEqual({
"a": "string",
"b": "number",
})
expect(res.body.rows.length).toEqual(1) expect(res.body.rows.length).toEqual(1)
expect(events.query.previewed).toBeCalledTimes(1) expect(events.query.previewed).toBeCalledTimes(1)
expect(events.query.previewed).toBeCalledWith(datasource, query) expect(events.query.previewed).toBeCalledWith(datasource, query)
@ -289,7 +292,11 @@ describe("/queries", () => {
queryString: "test={{ variable2 }}", queryString: "test={{ variable2 }}",
}) })
// these responses come from the mock // these responses come from the mock
expect(res.body.schemaFields).toEqual(["url", "opts", "value"]) expect(res.body.schemaFields).toEqual({
"opts": "json",
"url": "string",
"value": "string",
})
expect(res.body.rows[0].url).toEqual("http://www.google.com?test=1") expect(res.body.rows[0].url).toEqual("http://www.google.com?test=1")
}) })
@ -299,7 +306,11 @@ describe("/queries", () => {
path: "www.google.com", path: "www.google.com",
queryString: "test={{ variable3 }}", queryString: "test={{ variable3 }}",
}) })
expect(res.body.schemaFields).toEqual(["url", "opts", "value"]) expect(res.body.schemaFields).toEqual({
"opts": "json",
"url": "string",
"value": "string"
})
expect(res.body.rows[0].url).toContain("doctype html") expect(res.body.rows[0].url).toContain("doctype html")
}) })
@ -318,7 +329,11 @@ describe("/queries", () => {
path: "www.failonce.com", path: "www.failonce.com",
queryString: "test={{ variable3 }}", queryString: "test={{ variable3 }}",
}) })
expect(res.body.schemaFields).toEqual(["fails", "url", "opts"]) expect(res.body.schemaFields).toEqual({
"fails": "number",
"opts": "json",
"url": "string"
})
expect(res.body.rows[0].fails).toEqual(1) expect(res.body.rows[0].fails).toEqual(1)
}) })

View File

@ -53,7 +53,7 @@ const INTEGRATIONS = {
} }
// optionally add oracle integration if the oracle binary can be installed // optionally add oracle integration if the oracle binary can be installed
if (!(process.arch === "arm64" && process.platform === "darwin")) { if (process.arch && !process.arch.startsWith("arm")) {
const oracle = require("./oracle") const oracle = require("./oracle")
DEFINITIONS[SourceNames.ORACLE] = oracle.schema DEFINITIONS[SourceNames.ORACLE] = oracle.schema
INTEGRATIONS[SourceNames.ORACLE] = oracle.integration INTEGRATIONS[SourceNames.ORACLE] = oracle.integration

View File

@ -1080,12 +1080,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.220-alpha.3": "@budibase/backend-core@1.1.2":
version "1.0.220-alpha.3" version "1.1.2"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.220-alpha.3.tgz#62ca7f5c592e1efa9ed25abcdbafd60207961333" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.2.tgz#a95703605db2a757913c669427a1d3d7894b0cc6"
integrity sha512-spX86t09B0h8vAiKDpm65b/wW22NRQtjRhJLFaD4bkV+rFoKi3WCVmxp/ah4k6AIQ4Q3aZQPEIsxAw4TNfQjMA== integrity sha512-8dQTom7YCFySm40DHKA22YNKW9g1v6CkTg20vUmM8rMga5RrxDqQYJ3Ikgz2QRjQ9aT5kw/MIhHXM/Xgi8LrDw==
dependencies: dependencies:
"@budibase/types" "^1.0.220-alpha.3" "@budibase/types" "^1.1.2"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
bcrypt "5.0.1" bcrypt "5.0.1"
@ -1162,13 +1162,13 @@
svelte-flatpickr "^3.2.3" svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0" svelte-portal "^1.0.0"
"@budibase/pro@1.0.220-alpha.3": "@budibase/pro@1.1.2":
version "1.0.220-alpha.3" version "1.1.2"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.220-alpha.3.tgz#8384237f8ab72c1494d3b6b728b58efa2a29c999" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.2.tgz#6c061579eb9d34dcb6509e83596bb7019fc345fd"
integrity sha512-mYnuw9HWmJM4IrS8uhJuOyX7oCfEclQQ8ak7UlAZoTmM3zxWTzJL1dIbMNKo8YvAv/w45FvW6QgiYjajXxG3XA== integrity sha512-gdZasKfcC/eCqkiXBlErogHJN+5Sdxf3tA9xRMxehHXb/4eY+gOBEugAt/1/mI5GoiP509XWbO71JcGImPyRzg==
dependencies: dependencies:
"@budibase/backend-core" "1.0.220-alpha.3" "@budibase/backend-core" "1.1.2"
"@budibase/types" "1.0.220-alpha.3" "@budibase/types" "1.1.2"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@budibase/standard-components@^0.9.139": "@budibase/standard-components@^0.9.139":
@ -1189,10 +1189,10 @@
svelte-apexcharts "^1.0.2" svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0" svelte-flatpickr "^3.1.0"
"@budibase/types@1.0.220-alpha.3", "@budibase/types@^1.0.220-alpha.3": "@budibase/types@1.1.2", "@budibase/types@^1.1.2":
version "1.0.220-alpha.3" version "1.1.2"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.220-alpha.3.tgz#c63931cd25308e13143c1673850323cb3b60c159" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.2.tgz#696cf142856a4a60e0c3f48cc95eae965c43ae44"
integrity sha512-iLcXUVaVfJE69LQGJFOBCjLS4pXceE0hAIQFio9kc2sP2w0SwvvhMwOVfyNERKycy1EQ+qw6BhlY00ceMZ7szQ== integrity sha512-u377MZHErqaCnRdqX7NIi4CU090j7SkbIPJ2XYghcMzW7jcRz87N+Ehi8do3JnrXN6LZS98PiKo2hI33GTD0DQ==
"@bull-board/api@3.7.0": "@bull-board/api@3.7.0":
version "3.7.0" version "3.7.0"

View File

@ -75,7 +75,7 @@ function buildConfigSaveValidation() {
{ is: Configs.OIDC, then: oidcValidation() } { is: Configs.OIDC, then: oidcValidation() }
], ],
}), }),
}).required(), }).required().unknown(true),
) )
} }
@ -84,14 +84,14 @@ function buildUploadValidation() {
return joiValidator.params(Joi.object({ return joiValidator.params(Joi.object({
type: Joi.string().valid(...Object.values(Configs)).required(), type: Joi.string().valid(...Object.values(Configs)).required(),
name: Joi.string().required(), name: Joi.string().required(),
}).required()) }).required().unknown(true))
} }
function buildConfigGetValidation() { function buildConfigGetValidation() {
// prettier-ignore // prettier-ignore
return joiValidator.params(Joi.object({ return joiValidator.params(Joi.object({
type: Joi.string().valid(...Object.values(Configs)).required() type: Joi.string().valid(...Object.values(Configs)).required()
}).unknown(true).required()) }).required().unknown(true))
} }
router router

View File

@ -4,7 +4,7 @@ const nodemailer = require("nodemailer")
const fetch = require("node-fetch") const fetch = require("node-fetch")
// for the real email tests give them a long time to try complete/fail // for the real email tests give them a long time to try complete/fail
jest.setTimeout(30000) jest.setTimeout(60000)
describe("/api/global/email", () => { describe("/api/global/email", () => {

View File

@ -293,12 +293,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.220-alpha.3": "@budibase/backend-core@1.1.2":
version "1.0.220-alpha.3" version "1.1.2"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.220-alpha.3.tgz#62ca7f5c592e1efa9ed25abcdbafd60207961333" resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.2.tgz#a95703605db2a757913c669427a1d3d7894b0cc6"
integrity sha512-spX86t09B0h8vAiKDpm65b/wW22NRQtjRhJLFaD4bkV+rFoKi3WCVmxp/ah4k6AIQ4Q3aZQPEIsxAw4TNfQjMA== integrity sha512-8dQTom7YCFySm40DHKA22YNKW9g1v6CkTg20vUmM8rMga5RrxDqQYJ3Ikgz2QRjQ9aT5kw/MIhHXM/Xgi8LrDw==
dependencies: dependencies:
"@budibase/types" "^1.0.220-alpha.3" "@budibase/types" "^1.1.2"
"@techpass/passport-openidconnect" "0.3.2" "@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0" aws-sdk "2.1030.0"
bcrypt "5.0.1" bcrypt "5.0.1"
@ -326,19 +326,19 @@
uuid "8.3.2" uuid "8.3.2"
zlib "1.0.5" zlib "1.0.5"
"@budibase/pro@1.0.220-alpha.3": "@budibase/pro@1.1.2":
version "1.0.220-alpha.3" version "1.1.2"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.220-alpha.3.tgz#8384237f8ab72c1494d3b6b728b58efa2a29c999" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.2.tgz#6c061579eb9d34dcb6509e83596bb7019fc345fd"
integrity sha512-mYnuw9HWmJM4IrS8uhJuOyX7oCfEclQQ8ak7UlAZoTmM3zxWTzJL1dIbMNKo8YvAv/w45FvW6QgiYjajXxG3XA== integrity sha512-gdZasKfcC/eCqkiXBlErogHJN+5Sdxf3tA9xRMxehHXb/4eY+gOBEugAt/1/mI5GoiP509XWbO71JcGImPyRzg==
dependencies: dependencies:
"@budibase/backend-core" "1.0.220-alpha.3" "@budibase/backend-core" "1.1.2"
"@budibase/types" "1.0.220-alpha.3" "@budibase/types" "1.1.2"
node-fetch "^2.6.1" node-fetch "^2.6.1"
"@budibase/types@1.0.220-alpha.3", "@budibase/types@^1.0.220-alpha.3": "@budibase/types@1.1.2", "@budibase/types@^1.1.2":
version "1.0.220-alpha.3" version "1.1.2"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.220-alpha.3.tgz#c63931cd25308e13143c1673850323cb3b60c159" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.2.tgz#696cf142856a4a60e0c3f48cc95eae965c43ae44"
integrity sha512-iLcXUVaVfJE69LQGJFOBCjLS4pXceE0hAIQFio9kc2sP2w0SwvvhMwOVfyNERKycy1EQ+qw6BhlY00ceMZ7szQ== integrity sha512-u377MZHErqaCnRdqX7NIi4CU090j7SkbIPJ2XYghcMzW7jcRz87N+Ehi8do3JnrXN6LZS98PiKo2hI33GTD0DQ==
"@cspotcode/source-map-consumer@0.8.0": "@cspotcode/source-map-consumer@0.8.0":
version "0.8.0" version "0.8.0"