Skip to content

Commit

Permalink
Merge pull request #648 from nipunayf/fix-connector-names
Browse files Browse the repository at this point in the history
Improve connector names returned by connector search
  • Loading branch information
nipunayf authored Mar 5, 2025
2 parents 5884ca7 + d927621 commit 11f2e55
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public class ConnectorSearchCommand extends SearchCommand {
private static final String CONNECTORS_LANDING_JSON = "connectors_landing.json";
private static final Type CONNECTION_CATEGORY_LIST_TYPE = new TypeToken<Map<String, List<String>>>() { }.getType();

// TODO: Remove this once the name is retrieved from the library module
private static final String CONNECTOR_NAME_CORRECTION_JSON = "connector_name_correction.json";
private static final Type CONNECTOR_NAME_MAP_TYPE = new TypeToken<Map<String, String>>() { }.getType();
private static final Map<String, String> CONNECTOR_NAME_MAP =
LocalIndexCentral.getInstance().readJsonResource(CONNECTOR_NAME_CORRECTION_JSON, CONNECTOR_NAME_MAP_TYPE);

public ConnectorSearchCommand(Module module, LineRange position, Map<String, String> queryMap) {
super(module, position, queryMap);
}
Expand Down Expand Up @@ -85,9 +91,7 @@ protected Map<String, List<SearchResult>> fetchPopularItems() {
private static AvailableNode generateAvailableNode(SearchResult searchResult) {
SearchResult.Package packageInfo = searchResult.packageInfo();
Metadata metadata = new Metadata.Builder<>(null)
.label(packageInfo.name().substring(0, 1).toUpperCase(Locale.ROOT) + packageInfo.name().substring(1) +
" " +
searchResult.name())
.label(getConnectorName(searchResult, packageInfo))
.description(searchResult.description())
.icon(CommonUtils.generateIcon(packageInfo.org(),
packageInfo.name(),
Expand All @@ -104,4 +108,16 @@ private static AvailableNode generateAvailableNode(SearchResult searchResult) {
return new AvailableNode(metadata, codedata, true);
}

private static String getConnectorName(SearchResult searchResult, SearchResult.Package packageInfo) {
String connectorName = searchResult.name();
String rawPackageName = packageInfo.name();
String packageName = CONNECTOR_NAME_MAP.getOrDefault(rawPackageName, getLastPackagePrefix(rawPackageName));
return packageName + " " + connectorName;
}

private static String getLastPackagePrefix(String rawPackageName) {
String trimmedPackageName = rawPackageName.contains(".")
? rawPackageName.substring(rawPackageName.lastIndexOf('.') + 1) : rawPackageName;
return trimmedPackageName.substring(0, 1).toUpperCase(Locale.ROOT) + trimmedPackageName.substring(1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"http": "HTTP",
"grpc": "gRPC",
"mysql": "MySQL",
"mssql": "MS SQL",
"mongodb": "MongoDB",
"aws.dynamodb": "DynamoDB",
"oracledb": "OracleDB",
"postgresql": "PostgreSQL",
"sql": "SQL",
"azure.sqldb": "SQLDB",
"aws.sqs": "SQS",
"mqtt": "MQTT",
"rabbitmq": "RabbitMQ",
"graphql": "GraphQL",
"googleapis.clouddatastore": "Cloud Datastore",
"health.clients.fhir": "FHIR",
"ftp": "FTP",
"udp": "UDP",
"tcp": "TCP",
"persist.sql": "Persist",
"persist.inmemory": "Persist",
"persist.googlesheets": "Persist",
"persist.redis": "Persist"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"websocket:Client",
"tcp:Client",
"udp:Client",
"ftp:Client",
"websub:Client"
],
"Database": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"description": "Sample flow model",
"source": "empty.bal",
"kind": "CONNECTOR",
"source": "empty.bal",
"queryMap": {
"q": "database"
},
"categories": [
{
"metadata": {
"label": "Mongodb Database",
"label": "MongoDB Database",
"description": "Represents a MongoDB database.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_mongodb_5.1.0.png"
},
Expand All @@ -24,7 +24,7 @@
},
{
"metadata": {
"label": "Azure.sqldb Client",
"label": "SQLDB Client",
"description": "This is a generated connector from [Azure SQL DB API v1.0](https://docs.microsoft.com/en-us/azure/azure-sql/database/sql-database-paas-overview) OpenAPI specification.\nThis Azure SQL Database management API provides a RESTful set of web APIs that interact with Azure SQL Database services to manage your databases. The API enables users to create, retrieve, update, and delete databases, servers, and other entities.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_azure.sqldb_1.5.1.png"
},
Expand Down Expand Up @@ -56,7 +56,7 @@
},
{
"metadata": {
"label": "Mssql Client",
"label": "MS SQL Client",
"description": "Represents an MSSQL database client.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_mssql_1.14.0.png"
},
Expand All @@ -72,7 +72,7 @@
},
{
"metadata": {
"label": "Mysql Client",
"label": "MySQL Client",
"description": "Represents a MySQL database client.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_mysql_1.14.0.png"
},
Expand All @@ -88,7 +88,7 @@
},
{
"metadata": {
"label": "Postgresql Client",
"label": "PostgreSQL Client",
"description": "Represents a PostgreSQL database client.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_postgresql_1.14.0.png"
},
Expand Down Expand Up @@ -120,7 +120,7 @@
},
{
"metadata": {
"label": "Pinecone.vector Client",
"label": "Vector Client",
"description": "This is a generated connector for the `Vector Operations` under [Pinecone Vector Database API](https://docs.pinecone.io/reference) OpenAPI specification. Pinecone is a fully managed vector database which supports building developer-friendly, easily scalable, and high-performance vector search applications without infrastructure hassles.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_pinecone.vector_1.0.2.png"
},
Expand All @@ -136,7 +136,7 @@
},
{
"metadata": {
"label": "Pinecone.index Client",
"label": "Index Client",
"description": "This is a generated connector for the `Index Operations` under [Pinecone Vector Database API](https://docs.pinecone.io/reference) OpenAPI specification. Pinecone is a fully managed vector database which supports building developer-friendly, easily scalable, and high-performance vector search applications without infrastructure hassles.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_pinecone.index_1.0.2.png"
},
Expand Down Expand Up @@ -168,7 +168,7 @@
},
{
"metadata": {
"label": "Persist.redis RedisClient",
"label": "Persist RedisClient",
"description": "The client used by the generated persist clients to abstract and \nexecute Redis database operations that are required to perform CRUD operations.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_persist.redis_0.3.0.png"
},
Expand Down Expand Up @@ -264,7 +264,7 @@
},
{
"metadata": {
"label": "Zoho.crm.rest Client",
"label": "Rest Client",
"description": "This is a generated connector for [Zoho CRM](https://www.zoho.com/crm/developer/docs/api/v2/modules-api.html) OpenAPI specification.\nZoho CRM REST API provides the capability to unify customer data from across different applications and databases.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_zoho.crm.rest_1.3.1.png"
},
Expand All @@ -280,7 +280,7 @@
},
{
"metadata": {
"label": "Cdata.connect Client",
"label": "Connect Client",
"description": "The [Ballerina](https://ballerina.io/) connector for [CData Connect](https://cloud.cdata.com/docs/JDBC.html) \nallows you to programmatically access all of the CData Connect applications, databases, APIs, and services\nacross an organization via the Java Database Connectivity (JDBC) API using [Ballerina](https://ballerina.io/). \nFor detailed information on working with each data source, see [Data Sources](https://cloud.cdata.com/docs/Data-Sources.html).\nCData Connect supports a wide range of standard DDL commands, SQL commands, and SQL functions to query data sources. \nFor reference information on all the CData Connect SQL commands (i.e., DDL, DML, and query syntax), \nsee the [SQL Reference](https://cloud.cdata.com/docs/SQL-Reference.html).",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_cdata.connect_1.2.0.png"
},
Expand All @@ -296,7 +296,7 @@
},
{
"metadata": {
"label": "Files.com Client",
"label": "Com Client",
"description": "This is a generated connector from [Files.com API v1.0](https://www.files.com/) OpenAPI specification.\nWelcome to the Files.com API. Our REST API are designed for people who require the highest level of integration between Files.com and their own application, website, or database.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_files.com_1.5.1.png"
},
Expand All @@ -312,7 +312,7 @@
},
{
"metadata": {
"label": "Googleapis.clouddatastore Client",
"label": "Cloud Datastore Client",
"description": "This is a generated connector for [Google Cloud Datastore REST API v1](https://cloud.google.com/datastore/docs/reference/data/rest) OpenAPI specification.\nThe Google Cloud Datastore API provides the capability to access the schemaless NoSQL database to provide fully managed, robust, scalable storage for your application.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_googleapis.clouddatastore_1.5.1.png"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "Sample flow model",
"source": "empty.bal",
"kind": "CONNECTOR",
"source": "empty.bal",
"queryMap": {
"q": ""
},
Expand All @@ -13,7 +13,7 @@
"items": [
{
"metadata": {
"label": "Grpc Client",
"label": "gRPC Client",
"description": "The base client used in the generated client code to provide the capability for initiating the contact and executing remote calls with a remote gRPC service.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_grpc_1.13.2.png"
},
Expand All @@ -29,7 +29,7 @@
},
{
"metadata": {
"label": "Http Client",
"label": "HTTP Client",
"description": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes the functions for the standard HTTP methods forwarding a received request and sending requests\nusing custom HTTP verbs.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_http_2.13.3.png"
},
Expand All @@ -45,7 +45,7 @@
},
{
"metadata": {
"label": "Udp Client",
"label": "UDP Client",
"description": "Initializes the UDP connectionless client based on the provided configurations.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_udp_1.12.1.png"
},
Expand All @@ -59,6 +59,22 @@
},
"enabled": true
},
{
"metadata": {
"label": "FTP Client",
"description": "Represents an FTP client that intracts with an FTP server",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_ftp_2.12.0.png"
},
"codedata": {
"node": "NEW_CONNECTION",
"org": "ballerina",
"module": "ftp",
"object": "Client",
"symbol": "init",
"version": "2.12.0"
},
"enabled": true
},
{
"metadata": {
"label": "Websocket Client",
Expand All @@ -77,7 +93,7 @@
},
{
"metadata": {
"label": "Graphql Client",
"label": "GraphQL Client",
"description": "The Ballerina GraphQL client that can be used to communicate with GraphQL APIs.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_graphql_1.15.0.png"
},
Expand All @@ -93,7 +109,7 @@
},
{
"metadata": {
"label": "Tcp Client",
"label": "TCP Client",
"description": "Initializes the TCP connection client based on the provided configurations.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerina_tcp_1.12.1.png"
},
Expand All @@ -116,7 +132,7 @@
"items": [
{
"metadata": {
"label": "Mssql Client",
"label": "MS SQL Client",
"description": "Represents an MSSQL database client.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_mssql_1.14.0.png"
},
Expand All @@ -132,7 +148,7 @@
},
{
"metadata": {
"label": "Mongodb Client",
"label": "MongoDB Client",
"description": "Represents a MongoDB client that can be used to interact with a MongoDB server.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_mongodb_5.1.0.png"
},
Expand All @@ -148,7 +164,7 @@
},
{
"metadata": {
"label": "Mysql Client",
"label": "MySQL Client",
"description": "Represents a MySQL database client.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_mysql_1.14.0.png"
},
Expand Down Expand Up @@ -180,7 +196,7 @@
},
{
"metadata": {
"label": "Postgresql Client",
"label": "PostgreSQL Client",
"description": "Represents a PostgreSQL database client.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_postgresql_1.14.0.png"
},
Expand Down Expand Up @@ -251,7 +267,7 @@
},
{
"metadata": {
"label": "Rabbitmq Client",
"label": "RabbitMQ Client",
"description": "The Ballerina interface to provide AMQP Channel related functionality.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_rabbitmq_3.2.0.png"
},
Expand All @@ -274,7 +290,7 @@
"items": [
{
"metadata": {
"label": "Aws.dynamodb Client",
"label": "DynamoDB Client",
"description": "The Ballerina AWS DynamoDB connector provides the capability to access AWS Simple Email Service related operations.\nThis connector lets you to to send email messages to your customers.\n",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_aws.dynamodb_2.3.0.png"
},
Expand All @@ -290,7 +306,7 @@
},
{
"metadata": {
"label": "Aws.sqs Client",
"label": "SQS Client",
"description": "Ballerina Amazon SQS connector provides the capability to access Amazon SQS API.\nThis connector lets you to perform operations related to manage queues, send and receive messages. \n",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_aws.sqs_3.1.0.png"
},
Expand All @@ -306,7 +322,7 @@
},
{
"metadata": {
"label": "Aws.s3 Client",
"label": "S3 Client",
"description": "Ballerina Amazon S3 connector provides the capability to access AWS S3 API.\nThis connector lets you to get authorized access to AWS S3 buckets and objects.\n",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_aws.s3_3.5.0.png"
},
Expand All @@ -322,7 +338,7 @@
},
{
"metadata": {
"label": "Googleapis.gmail Client",
"label": "Gmail Client",
"description": "The Gmail API lets you view and manage Gmail mailbox data like threads, messages, and labels.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_googleapis.gmail_4.0.1.png"
},
Expand All @@ -338,7 +354,7 @@
},
{
"metadata": {
"label": "Googleapis.gcalendar Client",
"label": "Gcalendar Client",
"description": "Manipulates events and other calendar data.",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_googleapis.gcalendar_4.0.1.png"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"description": "Sample flow model",
"kind": "CONNECTOR",
"source": "empty.bal",
"queryMap": {
"q": "fhir"
},
"categories": [
{
"metadata": {
"label": "FHIR FHIRConnector",
"description": "This connector allows you to connect and interact with any FHIR server",
"icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_health.clients.fhir_2.1.0.png"
},
"codedata": {
"node": "NEW_CONNECTION",
"org": "ballerinax",
"module": "health.clients.fhir",
"object": "FHIRConnector",
"symbol": "init",
"version": "2.1.0"
},
"enabled": true
}
]
}
Loading

0 comments on commit 11f2e55

Please sign in to comment.