commit
ea6d26cc13
|
@ -90,8 +90,8 @@ export function createQueriesStore() {
|
|||
// Assume all the fields are strings and create a basic schema from the
|
||||
// unique fields returned by the server
|
||||
const schema = {}
|
||||
for (let field of result.schemaFields) {
|
||||
schema[field] = "string"
|
||||
for (let [field, type] of Object.entries(result.schemaFields)) {
|
||||
schema[field] = type || "string"
|
||||
}
|
||||
return { ...result, schema, rows: result.rows || [] }
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { generateQueryID, getQueryParams, isProdAppID } from "../../../db/utils"
|
||||
import { BaseQueryVerbs } from "../../../constants"
|
||||
import { BaseQueryVerbs, FieldTypes } from "../../../constants"
|
||||
import { Thread, ThreadType } from "../../../threads"
|
||||
import { save as saveDatasource } from "../datasource"
|
||||
import { RestImporter } from "./import"
|
||||
|
@ -154,10 +154,37 @@ export async function preview(ctx: any) {
|
|||
},
|
||||
})
|
||||
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)
|
||||
ctx.body = {
|
||||
rows,
|
||||
schemaFields: [...new Set(keys)],
|
||||
schemaFields,
|
||||
info,
|
||||
extra,
|
||||
}
|
||||
|
|
|
@ -215,7 +215,10 @@ describe("/queries", () => {
|
|||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
// 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(events.query.previewed).toBeCalledTimes(1)
|
||||
expect(events.query.previewed).toBeCalledWith(datasource, query)
|
||||
|
@ -289,7 +292,11 @@ describe("/queries", () => {
|
|||
queryString: "test={{ variable2 }}",
|
||||
})
|
||||
// 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")
|
||||
})
|
||||
|
||||
|
@ -299,7 +306,11 @@ describe("/queries", () => {
|
|||
path: "www.google.com",
|
||||
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")
|
||||
})
|
||||
|
||||
|
@ -318,7 +329,11 @@ describe("/queries", () => {
|
|||
path: "www.failonce.com",
|
||||
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)
|
||||
})
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ const INTEGRATIONS = {
|
|||
}
|
||||
|
||||
// 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")
|
||||
DEFINITIONS[SourceNames.ORACLE] = oracle.schema
|
||||
INTEGRATIONS[SourceNames.ORACLE] = oracle.integration
|
||||
|
|
|
@ -1080,12 +1080,12 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.220-alpha.3":
|
||||
version "1.0.220-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.220-alpha.3.tgz#62ca7f5c592e1efa9ed25abcdbafd60207961333"
|
||||
integrity sha512-spX86t09B0h8vAiKDpm65b/wW22NRQtjRhJLFaD4bkV+rFoKi3WCVmxp/ah4k6AIQ4Q3aZQPEIsxAw4TNfQjMA==
|
||||
"@budibase/backend-core@1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.2.tgz#a95703605db2a757913c669427a1d3d7894b0cc6"
|
||||
integrity sha512-8dQTom7YCFySm40DHKA22YNKW9g1v6CkTg20vUmM8rMga5RrxDqQYJ3Ikgz2QRjQ9aT5kw/MIhHXM/Xgi8LrDw==
|
||||
dependencies:
|
||||
"@budibase/types" "^1.0.220-alpha.3"
|
||||
"@budibase/types" "^1.1.2"
|
||||
"@techpass/passport-openidconnect" "0.3.2"
|
||||
aws-sdk "2.1030.0"
|
||||
bcrypt "5.0.1"
|
||||
|
@ -1162,13 +1162,13 @@
|
|||
svelte-flatpickr "^3.2.3"
|
||||
svelte-portal "^1.0.0"
|
||||
|
||||
"@budibase/pro@1.0.220-alpha.3":
|
||||
version "1.0.220-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.220-alpha.3.tgz#8384237f8ab72c1494d3b6b728b58efa2a29c999"
|
||||
integrity sha512-mYnuw9HWmJM4IrS8uhJuOyX7oCfEclQQ8ak7UlAZoTmM3zxWTzJL1dIbMNKo8YvAv/w45FvW6QgiYjajXxG3XA==
|
||||
"@budibase/pro@1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.2.tgz#6c061579eb9d34dcb6509e83596bb7019fc345fd"
|
||||
integrity sha512-gdZasKfcC/eCqkiXBlErogHJN+5Sdxf3tA9xRMxehHXb/4eY+gOBEugAt/1/mI5GoiP509XWbO71JcGImPyRzg==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.220-alpha.3"
|
||||
"@budibase/types" "1.0.220-alpha.3"
|
||||
"@budibase/backend-core" "1.1.2"
|
||||
"@budibase/types" "1.1.2"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@budibase/standard-components@^0.9.139":
|
||||
|
@ -1189,10 +1189,10 @@
|
|||
svelte-apexcharts "^1.0.2"
|
||||
svelte-flatpickr "^3.1.0"
|
||||
|
||||
"@budibase/types@1.0.220-alpha.3", "@budibase/types@^1.0.220-alpha.3":
|
||||
version "1.0.220-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.220-alpha.3.tgz#c63931cd25308e13143c1673850323cb3b60c159"
|
||||
integrity sha512-iLcXUVaVfJE69LQGJFOBCjLS4pXceE0hAIQFio9kc2sP2w0SwvvhMwOVfyNERKycy1EQ+qw6BhlY00ceMZ7szQ==
|
||||
"@budibase/types@1.1.2", "@budibase/types@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.2.tgz#696cf142856a4a60e0c3f48cc95eae965c43ae44"
|
||||
integrity sha512-u377MZHErqaCnRdqX7NIi4CU090j7SkbIPJ2XYghcMzW7jcRz87N+Ehi8do3JnrXN6LZS98PiKo2hI33GTD0DQ==
|
||||
|
||||
"@bull-board/api@3.7.0":
|
||||
version "3.7.0"
|
||||
|
|
|
@ -75,7 +75,7 @@ function buildConfigSaveValidation() {
|
|||
{ is: Configs.OIDC, then: oidcValidation() }
|
||||
],
|
||||
}),
|
||||
}).required(),
|
||||
}).required().unknown(true),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -84,14 +84,14 @@ function buildUploadValidation() {
|
|||
return joiValidator.params(Joi.object({
|
||||
type: Joi.string().valid(...Object.values(Configs)).required(),
|
||||
name: Joi.string().required(),
|
||||
}).required())
|
||||
}).required().unknown(true))
|
||||
}
|
||||
|
||||
function buildConfigGetValidation() {
|
||||
// prettier-ignore
|
||||
return joiValidator.params(Joi.object({
|
||||
type: Joi.string().valid(...Object.values(Configs)).required()
|
||||
}).unknown(true).required())
|
||||
}).required().unknown(true))
|
||||
}
|
||||
|
||||
router
|
||||
|
|
|
@ -4,7 +4,7 @@ const nodemailer = require("nodemailer")
|
|||
const fetch = require("node-fetch")
|
||||
|
||||
// for the real email tests give them a long time to try complete/fail
|
||||
jest.setTimeout(30000)
|
||||
jest.setTimeout(60000)
|
||||
|
||||
describe("/api/global/email", () => {
|
||||
|
||||
|
|
|
@ -293,12 +293,12 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.220-alpha.3":
|
||||
version "1.0.220-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.220-alpha.3.tgz#62ca7f5c592e1efa9ed25abcdbafd60207961333"
|
||||
integrity sha512-spX86t09B0h8vAiKDpm65b/wW22NRQtjRhJLFaD4bkV+rFoKi3WCVmxp/ah4k6AIQ4Q3aZQPEIsxAw4TNfQjMA==
|
||||
"@budibase/backend-core@1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.1.2.tgz#a95703605db2a757913c669427a1d3d7894b0cc6"
|
||||
integrity sha512-8dQTom7YCFySm40DHKA22YNKW9g1v6CkTg20vUmM8rMga5RrxDqQYJ3Ikgz2QRjQ9aT5kw/MIhHXM/Xgi8LrDw==
|
||||
dependencies:
|
||||
"@budibase/types" "^1.0.220-alpha.3"
|
||||
"@budibase/types" "^1.1.2"
|
||||
"@techpass/passport-openidconnect" "0.3.2"
|
||||
aws-sdk "2.1030.0"
|
||||
bcrypt "5.0.1"
|
||||
|
@ -326,19 +326,19 @@
|
|||
uuid "8.3.2"
|
||||
zlib "1.0.5"
|
||||
|
||||
"@budibase/pro@1.0.220-alpha.3":
|
||||
version "1.0.220-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.220-alpha.3.tgz#8384237f8ab72c1494d3b6b728b58efa2a29c999"
|
||||
integrity sha512-mYnuw9HWmJM4IrS8uhJuOyX7oCfEclQQ8ak7UlAZoTmM3zxWTzJL1dIbMNKo8YvAv/w45FvW6QgiYjajXxG3XA==
|
||||
"@budibase/pro@1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.1.2.tgz#6c061579eb9d34dcb6509e83596bb7019fc345fd"
|
||||
integrity sha512-gdZasKfcC/eCqkiXBlErogHJN+5Sdxf3tA9xRMxehHXb/4eY+gOBEugAt/1/mI5GoiP509XWbO71JcGImPyRzg==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.220-alpha.3"
|
||||
"@budibase/types" "1.0.220-alpha.3"
|
||||
"@budibase/backend-core" "1.1.2"
|
||||
"@budibase/types" "1.1.2"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@budibase/types@1.0.220-alpha.3", "@budibase/types@^1.0.220-alpha.3":
|
||||
version "1.0.220-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.220-alpha.3.tgz#c63931cd25308e13143c1673850323cb3b60c159"
|
||||
integrity sha512-iLcXUVaVfJE69LQGJFOBCjLS4pXceE0hAIQFio9kc2sP2w0SwvvhMwOVfyNERKycy1EQ+qw6BhlY00ceMZ7szQ==
|
||||
"@budibase/types@1.1.2", "@budibase/types@^1.1.2":
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.2.tgz#696cf142856a4a60e0c3f48cc95eae965c43ae44"
|
||||
integrity sha512-u377MZHErqaCnRdqX7NIi4CU090j7SkbIPJ2XYghcMzW7jcRz87N+Ehi8do3JnrXN6LZS98PiKo2hI33GTD0DQ==
|
||||
|
||||
"@cspotcode/source-map-consumer@0.8.0":
|
||||
version "0.8.0"
|
||||
|
|
Loading…
Reference in New Issue