Fixing validation for datasource plugins.

This commit is contained in:
mike12345567 2022-08-11 18:29:49 +01:00
parent ff84fd6bc9
commit d9a8604994
2 changed files with 6 additions and 6 deletions

View File

@ -26,9 +26,9 @@
"outputPath": "build" "outputPath": "build"
}, },
"dependencies": { "dependencies": {
"@budibase/backend-core": "1.2.28-alpha.0", "@budibase/backend-core": "^1.2.38",
"@budibase/string-templates": "1.2.28-alpha.0", "@budibase/string-templates": "^1.2.38",
"@budibase/types": "1.2.28-alpha.0", "@budibase/types": "^1.2.38",
"axios": "0.21.2", "axios": "0.21.2",
"chalk": "4.1.0", "chalk": "4.1.0",
"cli-progress": "3.11.2", "cli-progress": "3.11.2",

View File

@ -1,5 +1,5 @@
const { PluginTypes } = require("./constants") const { PluginTypes } = require("./constants")
const { DatasourceFieldTypes, QueryTypes } = require("@budibase/types") const { DatasourceFieldType, QueryType } = require("@budibase/types")
const joi = require("joi") const joi = require("joi")
const DATASOURCE_TYPES = [ const DATASOURCE_TYPES = [
@ -36,7 +36,7 @@ function validateDatasource(schema) {
const fieldValidator = joi.object({ const fieldValidator = joi.object({
type: joi type: joi
.string() .string()
.allow(...Object.values(DatasourceFieldTypes)) .allow(...Object.values(DatasourceFieldType))
.required(), .required(),
required: joi.boolean().required(), required: joi.boolean().required(),
default: joi.any(), default: joi.any(),
@ -45,7 +45,7 @@ function validateDatasource(schema) {
const queryValidator = joi const queryValidator = joi
.object({ .object({
type: joi.string().allow(...Object.values(QueryTypes)), type: joi.string().allow(...Object.values(QueryType)),
fields: joi.object().pattern(joi.string(), fieldValidator), fields: joi.object().pattern(joi.string(), fieldValidator),
}) })
.required() .required()