diff --git a/packages/builder/src/components/backend/Datasources/ConfigEditor/stores/validatedConfig.js b/packages/builder/src/components/backend/Datasources/ConfigEditor/stores/validatedConfig.js index d7607918df..7b8b2c0975 100644 --- a/packages/builder/src/components/backend/Datasources/ConfigEditor/stores/validatedConfig.js +++ b/packages/builder/src/components/backend/Datasources/ConfigEditor/stores/validatedConfig.js @@ -46,6 +46,19 @@ export const createValidatedConfigStore = (integration, config) => { value.forEach(field => { newStore[field.key] = field.value }) + if (!integration.datasource[key].config?.nestedFields) { + value.forEach(field => { + newStore[field.key] = field.value + }) + } else { + newStore[key] = value.reduce( + (p, field) => ({ + ...p, + [field.key]: field.value, + }), + {} + ) + } } else { newStore[key] = value } diff --git a/packages/server/src/integrations/microsoftSqlServer.ts b/packages/server/src/integrations/microsoftSqlServer.ts index 09ebdfca38..8629d3f49b 100644 --- a/packages/server/src/integrations/microsoftSqlServer.ts +++ b/packages/server/src/integrations/microsoftSqlServer.ts @@ -38,9 +38,11 @@ interface MSSQLConfig { schema: string encrypt?: boolean authType?: MSSQLConfigAuthType - adConfig_clientId: string - adConfig_clientSecret: string - adConfig_tenantId: string + adConfig?: { + clientId: string + clientSecret: string + tenantId: string + } } const SCHEMA: Integration = { @@ -95,7 +97,7 @@ const SCHEMA: Integration = { default: true, display: "Configure Active Directory", hidden: "'{{authType}}' !== 'Active Directory'", - config: { openByDefault: true }, + config: { openByDefault: true, nestedFields: true }, fields: { clientId: { type: DatasourceFieldType.STRING, @@ -161,7 +163,7 @@ class SqlServerIntegration extends Sql implements DatasourcePlus { await this.connect() response.connected = true } catch (e: any) { - response.error = e.message as string + response.error = e.message } return response } @@ -187,11 +189,12 @@ class SqlServerIntegration extends Sql implements DatasourcePlus { delete clientCfg.encrypt if (this.config.authType === MSSQLConfigAuthType.ACTIVE_DIRECTORY) { + const { clientId, tenantId, clientSecret } = this.config.adConfig! const clientApp = new ConfidentialClientApplication({ auth: { - clientId: this.config.adConfig_clientId, - authority: `https://login.microsoftonline.com/${this.config.adConfig_tenantId}`, - clientSecret: this.config.adConfig_clientSecret, + clientId, + authority: `https://login.microsoftonline.com/${tenantId}`, + clientSecret, }, }) diff --git a/packages/types/src/sdk/datasources.ts b/packages/types/src/sdk/datasources.ts index bca242c847..d2e3946778 100644 --- a/packages/types/src/sdk/datasources.ts +++ b/packages/types/src/sdk/datasources.ts @@ -120,7 +120,7 @@ interface DatasourceSelectFieldConfig extends DatasourceBasicFieldConfig { interface DatasourceFieldGroupConfig extends DatasourceBasicFieldConfig { type: DatasourceFieldType.FIELD_GROUP - config: { openByDefault?: boolean } + config: { openByDefault?: boolean; nestedFields?: boolean } } type DatasourceFieldConfig =