From f1278312abe31cb1c92a1f64487db8e23b66982a Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 19 Mar 2024 15:58:25 +0000 Subject: [PATCH 1/2] Reenable no-case-declarations. --- .eslintrc.json | 2 -- packages/backend-core/src/auth/auth.ts | 6 ++++-- packages/server/src/api/controllers/plugin/index.ts | 9 ++++++--- .../src/api/controllers/query/import/sources/openapi2.ts | 6 ++++-- .../src/api/controllers/query/import/sources/openapi3.ts | 3 ++- packages/server/src/integrations/base/sqlTable.ts | 3 ++- packages/server/src/integrations/microsoftSqlServer.ts | 6 ++++-- packages/server/src/integrations/rest.ts | 6 ++++-- packages/server/src/sdk/app/rows/search/utils.ts | 3 ++- .../src/utilities/rowProcessor/bbReferenceProcessor.ts | 8 ++++---- packages/server/src/utilities/schema.ts | 4 ++-- 11 files changed, 34 insertions(+), 22 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d93c086578..824868a975 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -39,7 +39,6 @@ "extends": ["eslint:recommended"], "rules": { "no-unused-vars": "off", - "no-case-declarations": "off", "no-undef": "off", "no-prototype-builtins": "off", "local-rules/no-budibase-imports": "error" @@ -56,7 +55,6 @@ }, "rules": { "no-unused-vars": "off", - "no-case-declarations": "off", "no-undef": "off", "no-prototype-builtins": "off", "local-rules/no-test-com": "error", diff --git a/packages/backend-core/src/auth/auth.ts b/packages/backend-core/src/auth/auth.ts index 1951c7986c..87ac46cf1c 100644 --- a/packages/backend-core/src/auth/auth.ts +++ b/packages/backend-core/src/auth/auth.ts @@ -133,7 +133,7 @@ export async function refreshOAuthToken( configId?: string ): Promise { switch (providerType) { - case SSOProviderType.OIDC: + case SSOProviderType.OIDC: { if (!configId) { return { err: { data: "OIDC config id not provided" } } } @@ -142,12 +142,14 @@ export async function refreshOAuthToken( return { err: { data: "OIDC configuration not found" } } } return refreshOIDCAccessToken(oidcConfig, refreshToken) - case SSOProviderType.GOOGLE: + } + case SSOProviderType.GOOGLE: { let googleConfig = await configs.getGoogleConfig() if (!googleConfig) { return { err: { data: "Google configuration not found" } } } return refreshGoogleAccessToken(googleConfig, refreshToken) + } } } diff --git a/packages/server/src/api/controllers/plugin/index.ts b/packages/server/src/api/controllers/plugin/index.ts index a8a451c98c..c7d4912db3 100644 --- a/packages/server/src/api/controllers/plugin/index.ts +++ b/packages/server/src/api/controllers/plugin/index.ts @@ -39,25 +39,28 @@ export async function create(ctx: any) { let name = "PLUGIN_" + Math.floor(100000 + Math.random() * 900000) switch (source) { - case PluginSource.NPM: + case PluginSource.NPM: { const { metadata: metadataNpm, directory: directoryNpm } = await npmUpload(url, name) metadata = metadataNpm directory = directoryNpm break - case PluginSource.GITHUB: + } + case PluginSource.GITHUB: { const { metadata: metadataGithub, directory: directoryGithub } = await githubUpload(url, name, githubToken) metadata = metadataGithub directory = directoryGithub break - case PluginSource.URL: + } + case PluginSource.URL: { const headersObj = headers || {} const { metadata: metadataUrl, directory: directoryUrl } = await urlUpload(url, name, headersObj) metadata = metadataUrl directory = directoryUrl break + } } pluginCore.validate(metadata?.schema) diff --git a/packages/server/src/api/controllers/query/import/sources/openapi2.ts b/packages/server/src/api/controllers/query/import/sources/openapi2.ts index 230647475e..6eb4766c70 100644 --- a/packages/server/src/api/controllers/query/import/sources/openapi2.ts +++ b/packages/server/src/api/controllers/query/import/sources/openapi2.ts @@ -109,13 +109,14 @@ export class OpenAPI2 extends OpenAPISource { for (let param of allParams) { if (parameterNotRef(param)) { switch (param.in) { - case "query": + case "query": { let prefix = "" if (queryString) { prefix = "&" } queryString = `${queryString}${prefix}${param.name}={{${param.name}}}` break + } case "header": headers[param.name] = `{{${param.name}}}` break @@ -125,7 +126,7 @@ export class OpenAPI2 extends OpenAPISource { case "formData": // future enhancement break - case "body": + case "body": { // set the request body to the example provided // future enhancement: generate an example from the schema let bodyParam: OpenAPIV2.InBodyParameterObject = @@ -135,6 +136,7 @@ export class OpenAPI2 extends OpenAPISource { requestBody = schema.example } break + } } // add the parameter if it can be bound in our config diff --git a/packages/server/src/api/controllers/query/import/sources/openapi3.ts b/packages/server/src/api/controllers/query/import/sources/openapi3.ts index f86f684c32..f6755c69ad 100644 --- a/packages/server/src/api/controllers/query/import/sources/openapi3.ts +++ b/packages/server/src/api/controllers/query/import/sources/openapi3.ts @@ -161,13 +161,14 @@ export class OpenAPI3 extends OpenAPISource { for (let param of allParams) { if (parameterNotRef(param)) { switch (param.in) { - case "query": + case "query": { let prefix = "" if (queryString) { prefix = "&" } queryString = `${queryString}${prefix}${param.name}={{${param.name}}}` break + } case "header": headers[param.name] = `{{${param.name}}}` break diff --git a/packages/server/src/integrations/base/sqlTable.ts b/packages/server/src/integrations/base/sqlTable.ts index f3560791e6..06c2184549 100644 --- a/packages/server/src/integrations/base/sqlTable.ts +++ b/packages/server/src/integrations/base/sqlTable.ts @@ -59,7 +59,7 @@ function generateSchema( case FieldType.BARCODEQR: schema.text(key) break - case FieldType.BB_REFERENCE: + case FieldType.BB_REFERENCE: { const subtype = column.subtype as FieldSubtype switch (subtype) { case FieldSubtype.USER: @@ -72,6 +72,7 @@ function generateSchema( throw utils.unreachable(subtype) } break + } case FieldType.NUMBER: // if meta is specified then this is a junction table entry if (column.meta && column.meta.toKey && column.meta.toTable) { diff --git a/packages/server/src/integrations/microsoftSqlServer.ts b/packages/server/src/integrations/microsoftSqlServer.ts index c79eb136ed..3c06f58cf4 100644 --- a/packages/server/src/integrations/microsoftSqlServer.ts +++ b/packages/server/src/integrations/microsoftSqlServer.ts @@ -254,7 +254,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus { } switch (this.config.authType) { - case MSSQLConfigAuthType.AZURE_ACTIVE_DIRECTORY: + case MSSQLConfigAuthType.AZURE_ACTIVE_DIRECTORY: { const { clientId, tenantId, clientSecret } = this.config.adConfig || {} const clientApp = new ConfidentialClientApplication({ @@ -276,7 +276,8 @@ class SqlServerIntegration extends Sql implements DatasourcePlus { }, } break - case MSSQLConfigAuthType.NTLM: + } + case MSSQLConfigAuthType.NTLM: { const { domain, trustServerCertificate } = this.config.ntlmConfig || {} clientCfg.authentication = { @@ -288,6 +289,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus { clientCfg.options ??= {} clientCfg.options.trustServerCertificate = !!trustServerCertificate break + } case null: case undefined: break diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index 44c62f60b7..5fa35cc667 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -283,7 +283,7 @@ class RestIntegration implements IntegrationBase { // content type defaults to plaintext input.body = string break - case BodyTypes.ENCODED: + case BodyTypes.ENCODED: { const params = new URLSearchParams() for (let [key, value] of Object.entries(object)) { params.append(key, value as string) @@ -293,7 +293,8 @@ class RestIntegration implements IntegrationBase { }) input.body = params break - case BodyTypes.FORM_DATA: + } + case BodyTypes.FORM_DATA: { const form = new FormData() for (let [key, value] of Object.entries(object)) { form.append(key, value) @@ -303,6 +304,7 @@ class RestIntegration implements IntegrationBase { }) input.body = form break + } case BodyTypes.XML: if (object != null && Object.keys(object).length) { string = new XmlBuilder().buildObject(object) diff --git a/packages/server/src/sdk/app/rows/search/utils.ts b/packages/server/src/sdk/app/rows/search/utils.ts index 5d93dcaca2..d300fdbef0 100644 --- a/packages/server/src/sdk/app/rows/search/utils.ts +++ b/packages/server/src/sdk/app/rows/search/utils.ts @@ -66,7 +66,7 @@ export function searchInputMapping(table: Table, options: SearchParams) { } for (let [key, column] of Object.entries(table.schema)) { switch (column.type) { - case FieldType.BB_REFERENCE: + case FieldType.BB_REFERENCE: { const subtype = column.subtype as FieldSubtype switch (subtype) { case FieldSubtype.USER: @@ -77,6 +77,7 @@ export function searchInputMapping(table: Table, options: SearchParams) { utils.unreachable(subtype) } break + } } } return options diff --git a/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts b/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts index c7b8998bad..31f1f5e575 100644 --- a/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts +++ b/packages/server/src/utilities/rowProcessor/bbReferenceProcessor.ts @@ -41,7 +41,7 @@ export async function processInputBBReferences( switch (subtype) { case FieldSubtype.USER: - case FieldSubtype.USERS: + case FieldSubtype.USERS: { const { notFoundIds } = await cache.user.getUsers(referenceIds) if (notFoundIds?.length) { @@ -53,7 +53,7 @@ export async function processInputBBReferences( } return referenceIds.join(",") || null - + } default: throw utils.unreachable(subtype) } @@ -73,7 +73,7 @@ export async function processOutputBBReferences( switch (subtype) { case FieldSubtype.USER: - case FieldSubtype.USERS: + case FieldSubtype.USERS: { const { users } = await cache.user.getUsers(ids) if (!users.length) { return undefined @@ -86,7 +86,7 @@ export async function processOutputBBReferences( firstName: u.firstName, lastName: u.lastName, })) - + } default: throw utils.unreachable(subtype) } diff --git a/packages/server/src/utilities/schema.ts b/packages/server/src/utilities/schema.ts index 500e922d65..7d9e41e5e9 100644 --- a/packages/server/src/utilities/schema.ts +++ b/packages/server/src/utilities/schema.ts @@ -191,7 +191,7 @@ function isValidBBReference( ): boolean { switch (columnSubtype) { case FieldSubtype.USER: - case FieldSubtype.USERS: + case FieldSubtype.USERS: { if (typeof columnData !== "string") { return false } @@ -208,7 +208,7 @@ function isValidBBReference( user => !db.isGlobalUserID(user._id) ) return !constainsWrongId - + } default: throw utils.unreachable(columnSubtype) } From 65388c74272053eeaed1ceac59d360b854a63810 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 19 Mar 2024 15:59:43 +0000 Subject: [PATCH 2/2] Update pro reference. --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index cbc1197dc4..4f183993af 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit cbc1197dc4b6982c1fcdc8c99b53bf9292e6e3b2 +Subproject commit 4f183993af024e5ddec1b90981fb9049a3c6c412