-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to ConnectorType.configuration #4557
Conversation
} | ||
} | ||
})(); | ||
const connectorUpdater = UPDATE_CONNECTOR_BY_TYPE[connector.type]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely removed everything related to configuration from the /update endpoint.
connectors/src/connectors/index.ts
Outdated
@@ -298,6 +306,35 @@ export const GET_CONNECTOR_CONFIG_BY_TYPE: Record< | |||
}, | |||
}; | |||
|
|||
export const SET_CONNECTOR_CONFIGURATION_BY_TYPE: Record< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now everything is using the old /config/
interface except the webcrawler.
@@ -39,31 +36,44 @@ import { | |||
|
|||
export async function createWebcrawlerConnector( | |||
dataSourceConfig: DataSourceConfig, | |||
urlConfig: CreateConnectorUrlRequestBody | |||
connectionId: string, | |||
configuration?: unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration should be of known type WebCrawlerConfigurationType
here to follow the same design as setWebcrawlerConfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good. I still need another pass of review but left a first batch of comments 🙏
}, | ||
}); | ||
} | ||
if (!auth.user()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ducplicate of isBuilder on l62?
}); | ||
} | ||
|
||
if (!auth.isBuilder()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can simply rely on the switch below so duplicate as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think we can constraint the updateConnector front API iots back to requiring a connectorId ?
Let's also enforce a whitelist of connectors you can update the configuration of in front, allowing only webcrawler for now 🙏
CreateConnectorUrlRequestBodySchema, | ||
UpdateConnectorOAuthRequestBodySchema, | ||
]), | ||
connectionId: t.union([t.string, t.null, t.undefined]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why allow undefined / null here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to enforce that update pass a connection as in practice this update really is an update connection only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And connectorsAPI enforces it right?
@@ -95,7 +95,7 @@ async function handler( | |||
const connectorsAPI = new ConnectorsAPI(logger); | |||
const updateRes = await connectorsAPI.updateConnector({ | |||
connectorId: dataSource.connectorId.toString(), | |||
params: bodyValidation.right, | |||
connectionId: bodyValidation.right.connectionId || undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should never happen if we fix the iots?
|
||
const connectorsAPI = new ConnectorsAPI(logger); | ||
|
||
const updateRes = await connectorsAPI.updateConfiguration({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We likely want to enforce a whiltelist of configration users can update. For now webcrawler
(to avoid allowing them to change flags as we move them to configurations)
@@ -146,11 +153,6 @@ export function startServer(port: number) { | |||
getConnectorConfigAPIHandler | |||
); | |||
|
|||
app.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/
|
||
import type { DataSourceConfig } from "@connectors/types/data_source_config"; | ||
|
||
export type ConnectorCreatorOAuth = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/
|
||
break; | ||
} | ||
case "url": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/
@@ -16,19 +16,6 @@ export function isConnectorProvider(val: string): val is ConnectorProvider { | |||
return (CONNECTOR_PROVIDERS as unknown as string[]).includes(val); | |||
} | |||
|
|||
export const provider2createConnectorType: Record< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/
157ee15
to
ec2e4e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Please proceed to extensive testing of connector creation (webcrawler but other as well) + webcrawler updates as this is a rather big change :)
Fix managed/update renderConnectorType() Fully working for websites Clean up Cleaning up the createConnector Interface Clean up typing in connectors Removes unknown from connectorsAPI.updateConfiguration Removing unknown Cleaning up following @spolu's comments. Remvoe console.log() Just removing a comment Make connectionId non optional Make sure only webcrawler configuration can be updated by a user
ec2e4e6
to
b0128d8
Compare
Already did but will re-do it right now with the final commit. |
@spolu tested the following with the final commit:
All worked well |
* Tmp commit Fix managed/update renderConnectorType() Fully working for websites Clean up Cleaning up the createConnector Interface Clean up typing in connectors Removes unknown from connectorsAPI.updateConfiguration Removing unknown Cleaning up following @spolu's comments. Remvoe console.log() Just removing a comment Make connectionId non optional Make sure only webcrawler configuration can be updated by a user * Fix typing
Description
Task: https://github.com/dust-tt/tasks/issues/537
The goal of this PR is to introduce a new interface to manage connectors configurations.
ConnectorType
now has aconfiguration?:ConnectorConfiguration
field, withConnectorConfiguration
defined like that as of today:and will be defined like that in the future:
There is also a new
ConnectorsAPI.updateConfiguration(connectorId, configuration:unknown)
API.Getting the configuration is achieved by getting the
ConnectorType
.The configuration of the WebCrawler was moved to the new interface as part of this PR, Slack and GoogleDrive will come later.
The single key configuration system (
/connectors/:connector_id/config/:config_key
) is now deprecated and will be removed in the future.This is a big PR, I did not find a way to slice it in smaller pieces. This would have involved keeping an over complicated interface on the connector side just to split the PR, and it was nearly impossible to do it because the types for the interface changed a lot.
Risk
Deploy Plan