Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/convex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### New Features

#### Connections
- **Convex** - Connect to Convex two ways. The Convex provider card signs in with Convex in the browser, lists every cloud deployment on the team you authorize (production, development and previews), and creates a deploy key named Stroke for the one you pick. Convex (URL + key) connects any deployment by its URL and a deploy or admin key, including self-hosted backends and `npx convex dev --local`.
- **Browse and edit Convex tables** - Tables and their document counts in the sidebar, newest documents first, filters like `age > 30 AND plan == "pro"`, inline cell edits, and insert, replace and delete. Int64 values show and edit as whole numbers without losing precision.
- **Convex console** - Run a deployed function with its arguments, `messages:list {"limit": 5}`, or read a table with `users.limit(20)` and `users.get("<id>")`. A function can write, so read-only mode and the MCP server's read-only access refuse function calls.

### Bug Fixes
- Rejected tokens for PostHog, Xata and SingleStore no longer ask to check "the email and API key": the message names that provider's own fields.
22 changes: 22 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,28 @@ pub async fn firestore_request(
crate::db::firestore::request(&cfg, &method, &path, body.as_ref()).await
}

// ── Convex ────────────────────────────────────────────────────────────────────

#[tauri::command]
pub async fn test_convex(config: crate::db::convex::ConvexConfig) -> Result<(), String> {
crate::db::convex::ping(&config).await
}

#[tauri::command]
pub async fn connect_convex_db(state: Db<'_>, config: crate::db::convex::ConvexConfig) -> Result<(), String> {
crate::db::connection::connect_convex(state, config).await
}

/// One of the dashboard's system functions (`db::convex::SYSTEM` only).
#[tauri::command]
pub async fn convex_call(state: Db<'_>, path: String, args: serde_json::Value) -> Result<serde_json::Value, String> {
let cfg = match require_conn(&state)? {
ActiveConnection::Doc(crate::db::docdb::DocConn::Convex(cfg)) => cfg,
_ => return Err("Not connected to Convex".into()),
};
crate::db::convex::system_call(&cfg, &path, args).await
}

// ── Cassandra ─────────────────────────────────────────────────────────────────

#[tauri::command]
Expand Down
8 changes: 7 additions & 1 deletion src-tauri/src/db/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ pub enum ActiveConnection {
Clickhouse(ClickhouseConfig),
Redis(RedisConfig),
Dynamodb(crate::db::dynamodb::DynamoConfig),
/// CouchDB, Cassandra, Firestore: see `db::docdb`.
/// CouchDB, Cassandra, Firestore, Convex, ...: see `db::docdb`.
Doc(crate::db::docdb::DocConn),
Duckdb(DuckdbHandle),
Mssql(MssqlHandle),
Expand Down Expand Up @@ -1970,6 +1970,12 @@ pub async fn connect_neo4j(state: Db<'_>, config: crate::db::neo4j::Neo4jConfig)
set_conn(&state, Some(ActiveConnection::Doc(crate::db::docdb::DocConn::Neo4j(config))))
}

/// Convex: a deployment URL and its deploy or admin key.
pub async fn connect_convex(state: Db<'_>, config: crate::db::convex::ConvexConfig) -> Result<(), String> {
crate::db::convex::ping(&config).await?;
set_conn(&state, Some(ActiveConnection::Doc(crate::db::docdb::DocConn::Convex(config))))
}

pub async fn connect_firestore(state: Db<'_>, config: crate::db::firestore::FirestoreConfig) -> Result<(), String> {
crate::db::firestore::ping(&config).await?;
set_conn(&state, Some(ActiveConnection::Doc(crate::db::docdb::DocConn::Firestore(config))))
Expand Down
427 changes: 427 additions & 0 deletions src-tauri/src/db/convex.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src-tauri/src/db/couchdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ pub fn grid_cell(v: &Value) -> (Value, &'static str) {
("$numberLong", Value::String(_)) => (x.clone(), "long"),
("$numberDecimal", Value::String(_)) => (x.clone(), "decimal"),
("$uuid", Value::String(_)) => (x.clone(), "uuid"),
// Convex int64, already decimal (see `db::convex::decode`).
("$integer", Value::String(_)) => (x.clone(), "int64"),
_ => (v.clone(), "object"),
}
}
Expand Down
25 changes: 20 additions & 5 deletions src-tauri/src/db/docdb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Document and wide-column engines that share one connection slot
//! (`ActiveConnection::Doc`): CouchDB, Cassandra, Firestore, MongoDB,
//! Elasticsearch/OpenSearch. Each keeps its
//! Elasticsearch/OpenSearch, Convex. Each keeps its
//! own module; this file only routes the calls every engine answers.

use super::query::SqlResult;
Expand All @@ -15,6 +15,7 @@ pub enum DocConn {
Elastic(super::elastic::EsConfig),
Neo4j(super::neo4j::Neo4jConfig),
Influx(super::influx::InfluxConfig),
Convex(super::convex::ConvexConfig),
}

impl DocConn {
Expand All @@ -28,6 +29,7 @@ impl DocConn {
Self::Elastic(_) => "elasticsearch",
Self::Neo4j(_) => "neo4j",
Self::Influx(_) => "influxdb",
Self::Convex(_) => "convex",
}
}
}
Expand All @@ -42,6 +44,7 @@ pub async fn query(conn: &DocConn, stmt: &str) -> Result<SqlResult, String> {
DocConn::Elastic(c) => super::elastic::query(c, stmt).await,
DocConn::Neo4j(c) => super::neo4j::query(c, stmt).await,
DocConn::Influx(c) => super::influx::query(c, stmt).await,
DocConn::Convex(c) => super::convex::query(c, stmt).await,
}
}

Expand All @@ -51,6 +54,7 @@ pub async fn query(conn: &DocConn, stmt: &str) -> Result<SqlResult, String> {
pub async fn query_as(conn: &DocConn, stmt: &str, allow_write: bool) -> Result<SqlResult, String> {
match conn {
DocConn::Elastic(c) => super::elastic::query_as(c, stmt, allow_write).await,
DocConn::Convex(c) => super::convex::query_as(c, stmt, allow_write).await,
_ => query(conn, stmt).await,
}
}
Expand All @@ -65,6 +69,7 @@ pub async fn list_tables(conn: &DocConn) -> Result<Vec<TableInfo>, String> {
DocConn::Elastic(c) => super::elastic::list_indices(c).await?.into_iter().map(|i| i.name).collect(),
DocConn::Neo4j(c) => super::neo4j::labels(c).await?.into_iter().map(|(n, _)| n).collect(),
DocConn::Influx(c) => super::influx::measurements(c).await?,
DocConn::Convex(c) => super::convex::list_tables(c).await?,
};
Ok(names
.into_iter()
Expand All @@ -82,7 +87,7 @@ pub async fn list_schemas(conn: &DocConn) -> Result<Vec<String>, String> {
match conn {
DocConn::Mongo(m) => super::mongo::list_databases(m).await,
DocConn::Cassandra(s) => super::cassandra::list_keyspaces(s).await,
DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Elastic(_) | DocConn::Neo4j(_) | DocConn::Influx(_) => Ok(vec![FLAT_SCHEMA.to_string()]),
DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Elastic(_) | DocConn::Neo4j(_) | DocConn::Influx(_) | DocConn::Convex(_) => Ok(vec![FLAT_SCHEMA.to_string()]),
}
}

Expand Down Expand Up @@ -127,6 +132,16 @@ pub async fn list_tables_in(conn: &DocConn, schema: &str) -> Result<Vec<TableInf
DocConn::Elastic(c) => Ok(super::elastic::list_indices(c).await?.into_iter().map(|i| info(i.name, i.docs)).collect()),
DocConn::Neo4j(c) => Ok(super::neo4j::labels(c).await?.into_iter().map(|(n, k)| info(n, k)).collect()),
DocConn::Influx(c) => Ok(super::influx::measurements(c).await?.into_iter().map(|n| info(n, -1)).collect()),
DocConn::Convex(c) => {
let names = super::convex::list_tables(c).await?;
Ok(stream::iter(names.into_iter().map(|n| async move {
let count = super::convex::table_size(c, &n).await.unwrap_or(-1);
info(n, count)
}))
.buffered(8)
.collect()
.await)
}
}
}

Expand All @@ -148,7 +163,7 @@ pub async fn use_schema(conn: &DocConn, schema: &str) -> Result<(), String> {
}
s.use_keyspace(schema, true).await.map_err(|e| format!("Keyspace \"{schema}\": {e}"))
}
DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Elastic(_) | DocConn::Neo4j(_) | DocConn::Influx(_) => Ok(()),
DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Elastic(_) | DocConn::Neo4j(_) | DocConn::Influx(_) | DocConn::Convex(_) => Ok(()),
}
}

Expand All @@ -165,7 +180,7 @@ pub async fn columns_in(conn: &DocConn, schema: &str, table: &str) -> Result<Vec
}
// Mappings are the index's columns: typed fields, nested ones dotted.
DocConn::Elastic(c) => super::elastic::index_columns(c, table).await,
DocConn::Mongo(_) | DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Neo4j(_) | DocConn::Influx(_) => Ok(vec![]),
DocConn::Mongo(_) | DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Neo4j(_) | DocConn::Influx(_) | DocConn::Convex(_) => Ok(vec![]),
}
}

Expand All @@ -174,7 +189,7 @@ pub async fn columns_in(conn: &DocConn, schema: &str, table: &str) -> Result<Vec
pub async fn schema_columns_in(conn: &DocConn, schema: &str) -> Result<Vec<super::schema::TableColumnStructure>, String> {
match conn {
DocConn::Cassandra(s) => Ok(super::cassandra::columns_by_table(super::cassandra::keyspace_columns(s, schema).await?)),
DocConn::Mongo(_) | DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Elastic(_) | DocConn::Neo4j(_) | DocConn::Influx(_) => Ok(vec![]),
DocConn::Mongo(_) | DocConn::Couch(_) | DocConn::Firestore(_) | DocConn::Elastic(_) | DocConn::Neo4j(_) | DocConn::Influx(_) | DocConn::Convex(_) => Ok(vec![]),
}
}

Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub mod couchdb;
pub mod elastic;
pub mod cassandra;
pub mod firestore;
pub mod convex;
pub mod neo4j;
pub mod influx;
pub mod google_auth;
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,8 @@ pub fn run() {
commands::cassandra_tables,
commands::cassandra_describe,
commands::cassandra_page,
commands::test_convex,
commands::connect_convex_db,
commands::cassandra_save,
commands::cassandra_delete,
commands::test_firestore,
Expand All @@ -795,6 +797,7 @@ pub fn run() {
commands::test_odbc,
commands::connect_odbc_db,
commands::test_snowflake,
commands::convex_call,
commands::connect_snowflake_db,
commands::odbc_drivers,
commands::odbc_data_sources,
Expand Down
12 changes: 12 additions & 0 deletions src-tauri/src/mcp/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub enum Dialect {
Dynamo,
/// Neo4j: Cypher, read by its clauses (see `db::neo4j::cypher_level`).
Cypher,
/// Convex: a table read, or a deployed function that may write.
Convex,
}

impl Dialect {
Expand All @@ -56,6 +58,7 @@ impl Dialect {
"couchdb" | "firestore" | "influxdb" => Self::ReadOnlyDoc,
"dynamodb" => Self::Dynamo,
"neo4j" => Self::Cypher,
"convex" => Self::Convex,
_ => Self::Sql,
}
}
Expand All @@ -76,6 +79,10 @@ pub fn script_level_in(dialect: Dialect, sql: &str) -> u8 {
Dialect::Redis => redis_level(sql),
Dialect::Dynamo => dynamo_level(sql),
Dialect::ReadOnlyDoc => READ,
// A function's kind is only known by asking the deployment, so any
// call counts as a write here; `convex::query_as` lets a read-only
// session run the ones that are queries.
Dialect::Convex => if crate::db::convex::reads(sql) { READ } else { WRITE },
Dialect::Cypher => crate::db::neo4j::cypher_level(sql),
Dialect::Elastic => match crate::db::elastic::parse(sql) {
Ok(crate::db::elastic::Statement::Raw { method, path, .. }) => crate::db::elastic::request_level(&method, &path),
Expand Down Expand Up @@ -693,6 +700,11 @@ mod tests {
assert_eq!(Dialect::for_driver("neo4j"), Dialect::Cypher);
assert_eq!(script_level_in(Dialect::Cypher, "MATCH (n) WITH n DETACH DELETE n"), WRITE);
assert_eq!(script_level_in(Dialect::Cypher, "MATCH (n) RETURN n"), READ);
assert_eq!(Dialect::for_driver("convex"), Dialect::Convex);
assert_eq!(script_level_in(Dialect::Convex, "users.limit(5)"), READ);
assert_eq!(script_level_in(Dialect::Convex, r#"users.get("j57")"#), READ);
assert_eq!(script_level_in(Dialect::Convex, r#"messages:send {"body": "x"}"#), WRITE);
assert_eq!(script_level_in(Dialect::Convex, "not a statement"), WRITE);
let m = |s: &str| script_level_in(Dialect::Mongo, s);
assert_eq!(m(r#"db.createCollection("shop")"#), MODIFY);
assert_eq!(m("db.users.createIndex({email: 1}, {unique: true})"), MODIFY);
Expand Down
6 changes: 5 additions & 1 deletion src-tauri/src/mcp/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn sample_sql(conn: &ActiveConnection, schema: &str, table: &str, n: usize) -> R
"mongodb" => format!("db.getCollection(\"{table}\").find({{}}).limit({n})"),
"couchdb" => format!("{table}.find({{}}, {{\"limit\": {n}}})"),
"elasticsearch" | "opensearch" => format!("GET {table}/_search\n{{\"size\": {n}}}"),
"firestore" => format!("{table}.limit({n})"),
"firestore" | "convex" => format!("{table}.limit({n})"),
"cassandra" => format!("SELECT * FROM {}.{} LIMIT {n}", dq(schema), dq(table)),
other => return Err(format!("sample_rows is not available for {other}. Use execute_sql.")),
},
Expand Down Expand Up @@ -1149,6 +1149,10 @@ async fn describe_table(
let info = crate::db::influx::describe(c, table).await?;
Ok(json!({"table":table,"engine":"influxdb","tags":info["tags"],"fields":info["fields"],"note":"Read-only. Tags are indexed strings, fields hold the values, `time` is the timestamp. Always bound time and add LIMIT."}).to_string())
}
DocConn::Convex(c) => {
let count = crate::db::convex::table_size(c, table).await.unwrap_or(-1);
Ok(json!({"table":table,"engine":"convex","document_count":count,"note":"Convex tables are documents with _id and _creationTime. Read them with `table.limit(20)` or `table.get(\"<id>\")`; run a deployed function with `module:function {\"arg\": 1}`. Function calls may write."}).to_string())
}
// Typed columns where the engine keeps them (CQL, index mappings).
DocConn::Cassandra(_) | DocConn::Elastic(_) => {
let cols = crate::db::docdb::columns_in(d, schema, table).await?;
Expand Down
Loading
Loading