Merge branch 'master' into tests/shared-core-ci
This commit is contained in:
commit
7b5220116b
|
@ -39,7 +39,6 @@
|
||||||
"extends": ["eslint:recommended"],
|
"extends": ["eslint:recommended"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"no-case-declarations": "off",
|
|
||||||
"no-undef": "off",
|
"no-undef": "off",
|
||||||
"no-prototype-builtins": "off",
|
"no-prototype-builtins": "off",
|
||||||
"local-rules/no-budibase-imports": "error"
|
"local-rules/no-budibase-imports": "error"
|
||||||
|
@ -56,7 +55,6 @@
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"no-case-declarations": "off",
|
|
||||||
"no-undef": "off",
|
"no-undef": "off",
|
||||||
"no-prototype-builtins": "off",
|
"no-prototype-builtins": "off",
|
||||||
"local-rules/no-test-com": "error",
|
"local-rules/no-test-com": "error",
|
||||||
|
|
|
@ -133,7 +133,7 @@ export async function refreshOAuthToken(
|
||||||
configId?: string
|
configId?: string
|
||||||
): Promise<RefreshResponse> {
|
): Promise<RefreshResponse> {
|
||||||
switch (providerType) {
|
switch (providerType) {
|
||||||
case SSOProviderType.OIDC:
|
case SSOProviderType.OIDC: {
|
||||||
if (!configId) {
|
if (!configId) {
|
||||||
return { err: { data: "OIDC config id not provided" } }
|
return { err: { data: "OIDC config id not provided" } }
|
||||||
}
|
}
|
||||||
|
@ -142,12 +142,14 @@ export async function refreshOAuthToken(
|
||||||
return { err: { data: "OIDC configuration not found" } }
|
return { err: { data: "OIDC configuration not found" } }
|
||||||
}
|
}
|
||||||
return refreshOIDCAccessToken(oidcConfig, refreshToken)
|
return refreshOIDCAccessToken(oidcConfig, refreshToken)
|
||||||
case SSOProviderType.GOOGLE:
|
}
|
||||||
|
case SSOProviderType.GOOGLE: {
|
||||||
let googleConfig = await configs.getGoogleConfig()
|
let googleConfig = await configs.getGoogleConfig()
|
||||||
if (!googleConfig) {
|
if (!googleConfig) {
|
||||||
return { err: { data: "Google configuration not found" } }
|
return { err: { data: "Google configuration not found" } }
|
||||||
}
|
}
|
||||||
return refreshGoogleAccessToken(googleConfig, refreshToken)
|
return refreshGoogleAccessToken(googleConfig, refreshToken)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,25 +39,28 @@ export async function create(ctx: any) {
|
||||||
let name = "PLUGIN_" + Math.floor(100000 + Math.random() * 900000)
|
let name = "PLUGIN_" + Math.floor(100000 + Math.random() * 900000)
|
||||||
|
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case PluginSource.NPM:
|
case PluginSource.NPM: {
|
||||||
const { metadata: metadataNpm, directory: directoryNpm } =
|
const { metadata: metadataNpm, directory: directoryNpm } =
|
||||||
await npmUpload(url, name)
|
await npmUpload(url, name)
|
||||||
metadata = metadataNpm
|
metadata = metadataNpm
|
||||||
directory = directoryNpm
|
directory = directoryNpm
|
||||||
break
|
break
|
||||||
case PluginSource.GITHUB:
|
}
|
||||||
|
case PluginSource.GITHUB: {
|
||||||
const { metadata: metadataGithub, directory: directoryGithub } =
|
const { metadata: metadataGithub, directory: directoryGithub } =
|
||||||
await githubUpload(url, name, githubToken)
|
await githubUpload(url, name, githubToken)
|
||||||
metadata = metadataGithub
|
metadata = metadataGithub
|
||||||
directory = directoryGithub
|
directory = directoryGithub
|
||||||
break
|
break
|
||||||
case PluginSource.URL:
|
}
|
||||||
|
case PluginSource.URL: {
|
||||||
const headersObj = headers || {}
|
const headersObj = headers || {}
|
||||||
const { metadata: metadataUrl, directory: directoryUrl } =
|
const { metadata: metadataUrl, directory: directoryUrl } =
|
||||||
await urlUpload(url, name, headersObj)
|
await urlUpload(url, name, headersObj)
|
||||||
metadata = metadataUrl
|
metadata = metadataUrl
|
||||||
directory = directoryUrl
|
directory = directoryUrl
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginCore.validate(metadata?.schema)
|
pluginCore.validate(metadata?.schema)
|
||||||
|
|
|
@ -109,13 +109,14 @@ export class OpenAPI2 extends OpenAPISource {
|
||||||
for (let param of allParams) {
|
for (let param of allParams) {
|
||||||
if (parameterNotRef(param)) {
|
if (parameterNotRef(param)) {
|
||||||
switch (param.in) {
|
switch (param.in) {
|
||||||
case "query":
|
case "query": {
|
||||||
let prefix = ""
|
let prefix = ""
|
||||||
if (queryString) {
|
if (queryString) {
|
||||||
prefix = "&"
|
prefix = "&"
|
||||||
}
|
}
|
||||||
queryString = `${queryString}${prefix}${param.name}={{${param.name}}}`
|
queryString = `${queryString}${prefix}${param.name}={{${param.name}}}`
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case "header":
|
case "header":
|
||||||
headers[param.name] = `{{${param.name}}}`
|
headers[param.name] = `{{${param.name}}}`
|
||||||
break
|
break
|
||||||
|
@ -125,7 +126,7 @@ export class OpenAPI2 extends OpenAPISource {
|
||||||
case "formData":
|
case "formData":
|
||||||
// future enhancement
|
// future enhancement
|
||||||
break
|
break
|
||||||
case "body":
|
case "body": {
|
||||||
// set the request body to the example provided
|
// set the request body to the example provided
|
||||||
// future enhancement: generate an example from the schema
|
// future enhancement: generate an example from the schema
|
||||||
let bodyParam: OpenAPIV2.InBodyParameterObject =
|
let bodyParam: OpenAPIV2.InBodyParameterObject =
|
||||||
|
@ -135,6 +136,7 @@ export class OpenAPI2 extends OpenAPISource {
|
||||||
requestBody = schema.example
|
requestBody = schema.example
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the parameter if it can be bound in our config
|
// add the parameter if it can be bound in our config
|
||||||
|
|
|
@ -161,13 +161,14 @@ export class OpenAPI3 extends OpenAPISource {
|
||||||
for (let param of allParams) {
|
for (let param of allParams) {
|
||||||
if (parameterNotRef(param)) {
|
if (parameterNotRef(param)) {
|
||||||
switch (param.in) {
|
switch (param.in) {
|
||||||
case "query":
|
case "query": {
|
||||||
let prefix = ""
|
let prefix = ""
|
||||||
if (queryString) {
|
if (queryString) {
|
||||||
prefix = "&"
|
prefix = "&"
|
||||||
}
|
}
|
||||||
queryString = `${queryString}${prefix}${param.name}={{${param.name}}}`
|
queryString = `${queryString}${prefix}${param.name}={{${param.name}}}`
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case "header":
|
case "header":
|
||||||
headers[param.name] = `{{${param.name}}}`
|
headers[param.name] = `{{${param.name}}}`
|
||||||
break
|
break
|
||||||
|
|
|
@ -59,7 +59,7 @@ function generateSchema(
|
||||||
case FieldType.BARCODEQR:
|
case FieldType.BARCODEQR:
|
||||||
schema.text(key)
|
schema.text(key)
|
||||||
break
|
break
|
||||||
case FieldType.BB_REFERENCE:
|
case FieldType.BB_REFERENCE: {
|
||||||
const subtype = column.subtype as FieldSubtype
|
const subtype = column.subtype as FieldSubtype
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case FieldSubtype.USER:
|
case FieldSubtype.USER:
|
||||||
|
@ -72,6 +72,7 @@ function generateSchema(
|
||||||
throw utils.unreachable(subtype)
|
throw utils.unreachable(subtype)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case FieldType.NUMBER:
|
case FieldType.NUMBER:
|
||||||
// if meta is specified then this is a junction table entry
|
// if meta is specified then this is a junction table entry
|
||||||
if (column.meta && column.meta.toKey && column.meta.toTable) {
|
if (column.meta && column.meta.toKey && column.meta.toTable) {
|
||||||
|
|
|
@ -254,7 +254,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this.config.authType) {
|
switch (this.config.authType) {
|
||||||
case MSSQLConfigAuthType.AZURE_ACTIVE_DIRECTORY:
|
case MSSQLConfigAuthType.AZURE_ACTIVE_DIRECTORY: {
|
||||||
const { clientId, tenantId, clientSecret } =
|
const { clientId, tenantId, clientSecret } =
|
||||||
this.config.adConfig || {}
|
this.config.adConfig || {}
|
||||||
const clientApp = new ConfidentialClientApplication({
|
const clientApp = new ConfidentialClientApplication({
|
||||||
|
@ -276,7 +276,8 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case MSSQLConfigAuthType.NTLM:
|
}
|
||||||
|
case MSSQLConfigAuthType.NTLM: {
|
||||||
const { domain, trustServerCertificate } =
|
const { domain, trustServerCertificate } =
|
||||||
this.config.ntlmConfig || {}
|
this.config.ntlmConfig || {}
|
||||||
clientCfg.authentication = {
|
clientCfg.authentication = {
|
||||||
|
@ -288,6 +289,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
||||||
clientCfg.options ??= {}
|
clientCfg.options ??= {}
|
||||||
clientCfg.options.trustServerCertificate = !!trustServerCertificate
|
clientCfg.options.trustServerCertificate = !!trustServerCertificate
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case null:
|
case null:
|
||||||
case undefined:
|
case undefined:
|
||||||
break
|
break
|
||||||
|
|
|
@ -283,7 +283,7 @@ class RestIntegration implements IntegrationBase {
|
||||||
// content type defaults to plaintext
|
// content type defaults to plaintext
|
||||||
input.body = string
|
input.body = string
|
||||||
break
|
break
|
||||||
case BodyTypes.ENCODED:
|
case BodyTypes.ENCODED: {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
for (let [key, value] of Object.entries(object)) {
|
for (let [key, value] of Object.entries(object)) {
|
||||||
params.append(key, value as string)
|
params.append(key, value as string)
|
||||||
|
@ -293,7 +293,8 @@ class RestIntegration implements IntegrationBase {
|
||||||
})
|
})
|
||||||
input.body = params
|
input.body = params
|
||||||
break
|
break
|
||||||
case BodyTypes.FORM_DATA:
|
}
|
||||||
|
case BodyTypes.FORM_DATA: {
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
for (let [key, value] of Object.entries(object)) {
|
for (let [key, value] of Object.entries(object)) {
|
||||||
form.append(key, value)
|
form.append(key, value)
|
||||||
|
@ -303,6 +304,7 @@ class RestIntegration implements IntegrationBase {
|
||||||
})
|
})
|
||||||
input.body = form
|
input.body = form
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case BodyTypes.XML:
|
case BodyTypes.XML:
|
||||||
if (object != null && Object.keys(object).length) {
|
if (object != null && Object.keys(object).length) {
|
||||||
string = new XmlBuilder().buildObject(object)
|
string = new XmlBuilder().buildObject(object)
|
||||||
|
|
|
@ -66,7 +66,7 @@ export function searchInputMapping(table: Table, options: SearchParams) {
|
||||||
}
|
}
|
||||||
for (let [key, column] of Object.entries(table.schema)) {
|
for (let [key, column] of Object.entries(table.schema)) {
|
||||||
switch (column.type) {
|
switch (column.type) {
|
||||||
case FieldType.BB_REFERENCE:
|
case FieldType.BB_REFERENCE: {
|
||||||
const subtype = column.subtype as FieldSubtype
|
const subtype = column.subtype as FieldSubtype
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case FieldSubtype.USER:
|
case FieldSubtype.USER:
|
||||||
|
@ -77,6 +77,7 @@ export function searchInputMapping(table: Table, options: SearchParams) {
|
||||||
utils.unreachable(subtype)
|
utils.unreachable(subtype)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return options
|
return options
|
||||||
|
|
|
@ -41,7 +41,7 @@ export async function processInputBBReferences(
|
||||||
|
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case FieldSubtype.USER:
|
case FieldSubtype.USER:
|
||||||
case FieldSubtype.USERS:
|
case FieldSubtype.USERS: {
|
||||||
const { notFoundIds } = await cache.user.getUsers(referenceIds)
|
const { notFoundIds } = await cache.user.getUsers(referenceIds)
|
||||||
|
|
||||||
if (notFoundIds?.length) {
|
if (notFoundIds?.length) {
|
||||||
|
@ -53,7 +53,7 @@ export async function processInputBBReferences(
|
||||||
}
|
}
|
||||||
|
|
||||||
return referenceIds.join(",") || null
|
return referenceIds.join(",") || null
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw utils.unreachable(subtype)
|
throw utils.unreachable(subtype)
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ export async function processOutputBBReferences(
|
||||||
|
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case FieldSubtype.USER:
|
case FieldSubtype.USER:
|
||||||
case FieldSubtype.USERS:
|
case FieldSubtype.USERS: {
|
||||||
const { users } = await cache.user.getUsers(ids)
|
const { users } = await cache.user.getUsers(ids)
|
||||||
if (!users.length) {
|
if (!users.length) {
|
||||||
return undefined
|
return undefined
|
||||||
|
@ -86,7 +86,7 @@ export async function processOutputBBReferences(
|
||||||
firstName: u.firstName,
|
firstName: u.firstName,
|
||||||
lastName: u.lastName,
|
lastName: u.lastName,
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw utils.unreachable(subtype)
|
throw utils.unreachable(subtype)
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ function isValidBBReference(
|
||||||
): boolean {
|
): boolean {
|
||||||
switch (columnSubtype) {
|
switch (columnSubtype) {
|
||||||
case FieldSubtype.USER:
|
case FieldSubtype.USER:
|
||||||
case FieldSubtype.USERS:
|
case FieldSubtype.USERS: {
|
||||||
if (typeof columnData !== "string") {
|
if (typeof columnData !== "string") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ function isValidBBReference(
|
||||||
user => !db.isGlobalUserID(user._id)
|
user => !db.isGlobalUserID(user._id)
|
||||||
)
|
)
|
||||||
return !constainsWrongId
|
return !constainsWrongId
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw utils.unreachable(columnSubtype)
|
throw utils.unreachable(columnSubtype)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue