Skip to content
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

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

lasryaric
Copy link
Contributor

@lasryaric lasryaric commented Apr 3, 2024

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 a configuration?:ConnectorConfiguration field, with ConnectorConfiguration defined like that as of today:

export type ConnectorConfiguration = WebCrawlerConfigurationType;

and will be defined like that in the future:

export type ConnectorConfiguration = WebCrawlerConfigurationType | SlackConfigurationType | GoogleDriveConfigurationType | ...

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

}
}
})();
const connectorUpdater = UPDATE_CONNECTOR_BY_TYPE[connector.type];
Copy link
Contributor Author

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.

@@ -298,6 +306,35 @@ export const GET_CONNECTOR_CONFIG_BY_TYPE: Record<
},
};

export const SET_CONNECTOR_CONFIGURATION_BY_TYPE: Record<
Copy link
Contributor Author

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
Copy link
Contributor Author

@lasryaric lasryaric Apr 3, 2024

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

@lasryaric lasryaric requested a review from spolu April 3, 2024 16:17
Copy link
Contributor

@spolu spolu left a 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()) {
Copy link
Contributor

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()) {
Copy link
Contributor

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?

front/pages/api/w/[wId]/data_sources/managed.ts Outdated Show resolved Hide resolved
types/src/front/lib/connectors_api.ts Outdated Show resolved Hide resolved
types/src/connectors/api_handlers/create_connector.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@spolu spolu left a 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]),
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

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,
Copy link
Contributor

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({
Copy link
Contributor

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(
Copy link
Contributor

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 = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/


break;
}
case "url": {
Copy link
Contributor

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<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\o/

@lasryaric lasryaric force-pushed the aric-isolate_webcrawler_configuration branch 2 times, most recently from 157ee15 to ec2e4e6 Compare April 4, 2024 14:11
Copy link
Contributor

@spolu spolu left a 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
@lasryaric lasryaric force-pushed the aric-isolate_webcrawler_configuration branch from ec2e4e6 to b0128d8 Compare April 4, 2024 14:18
@lasryaric
Copy link
Contributor Author

LGTM
Please proceed to extensive testing of connector creation (webcrawler but other as well) + webcrawler updates as this is a rather big change :)

Already did but will re-do it right now with the final commit.

@lasryaric
Copy link
Contributor Author

lasryaric commented Apr 4, 2024

@spolu tested the following with the final commit:

  • Create a folder and upload 20 PDFs.
  • Connect a new Slack
  • Revoke my Slack authorization
  • Update my Slack connector, observed that it works again
  • Exact same thing with Google Drive
  • Created a Website
  • Changed all settings, observed that it worked
  • Deleted the website
  • Added another website

All worked well

@lasryaric lasryaric merged commit 4295a6c into main Apr 4, 2024
5 checks passed
@lasryaric lasryaric deleted the aric-isolate_webcrawler_configuration branch April 4, 2024 14:56
flvndvd pushed a commit that referenced this pull request May 26, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants