From ef89c5a80a5150e58e0ed0a3f7d913b21786655a Mon Sep 17 00:00:00 2001 From: broisnees Date: Wed, 18 Nov 2026 16:39:03 +0000 Subject: [PATCH] Add Xata and SingleStore providers Both sign in with a pasted key for now. Xata: an API key lists every branch of every project and connects with the branch's own credentials. SingleStore: a Management API key lists workspaces and starter workspaces; the API never returns a database password, so it is asked once and kept, as with Supabase. Both can move to OAuth later: Xata supports dynamic client registration, SingleStore needs a client ID. --- src-tauri/src/providers/mod.rs | 31 ++++- src-tauri/src/providers/singlestore.rs | 153 ++++++++++++++++++++++++ src-tauri/src/providers/xata.rs | 154 +++++++++++++++++++++++++ src/lib/connection-provider.js | 2 + src/lib/db-icons.js | 3 + src/lib/providers.js | 24 ++++ src/lib/stores/connections.js | 2 +- 7 files changed, 363 insertions(+), 6 deletions(-) create mode 100644 src-tauri/src/providers/singlestore.rs create mode 100644 src-tauri/src/providers/xata.rs diff --git a/src-tauri/src/providers/mod.rs b/src-tauri/src/providers/mod.rs index 17b8cf77..cd9c00e4 100644 --- a/src-tauri/src/providers/mod.rs +++ b/src-tauri/src/providers/mod.rs @@ -30,6 +30,8 @@ mod railway; mod tidb; mod turso; mod upstash; +mod xata; +mod singlestore; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use serde::{Deserialize, Serialize}; @@ -75,6 +77,8 @@ pub enum Provider { Nile, Upstash, PostHog, + Xata, + SingleStore, } /// How a provider signs the user in. @@ -103,13 +107,16 @@ impl Provider { "nile" => Ok(Self::Nile), "upstash" => Ok(Self::Upstash), "posthog" => Ok(Self::PostHog), + "xata" => Ok(Self::Xata), + "singlestore" => Ok(Self::SingleStore), other => Err(format!("Unknown provider: {other}")), } } - const ALL: [Provider; 10] = [ + const ALL: [Provider; 12] = [ Self::Neon, Self::Supabase, Self::PlanetScale, Self::Prisma, Self::TiDB, Self::Turso, Self::Railway, Self::Nile, Self::Upstash, Self::PostHog, + Self::Xata, Self::SingleStore, ]; /// The API host each listing and connect talks to, for `provider_warm`. @@ -125,6 +132,8 @@ impl Provider { Self::Railway => "https://backboard.railway.com", Self::Nile => "https://global.thenile.dev", Self::Upstash => "https://api.upstash.com", + Self::Xata => "https://api.xata.tech", + Self::SingleStore => "https://api.singlestore.com", Self::PostHog => return None, }) } @@ -142,6 +151,8 @@ impl Provider { Self::Nile => "nile", Self::Upstash => "upstash", Self::PostHog => "posthog", + Self::Xata => "xata", + Self::SingleStore => "singlestore", } } @@ -158,6 +169,8 @@ impl Provider { Self::Nile => "Nile", Self::Upstash => "Upstash", Self::PostHog => "PostHog", + Self::Xata => "Xata", + Self::SingleStore => "SingleStore", } } @@ -181,13 +194,15 @@ impl Provider { Self::Nile => nile::OAUTH, Self::Upstash => upstash::OAUTH, Self::PostHog => posthog::OAUTH, + Self::Xata => xata::OAUTH, + Self::SingleStore => singlestore::OAUTH, } } /// Whether a provider uses a pasted API credential instead of the browser /// OAuth dance: Upstash, which offers no OAuth to third-party apps. fn is_token_based(&self) -> bool { - matches!(self, Self::Upstash | Self::PostHog) + matches!(self, Self::Upstash | Self::PostHog | Self::Xata | Self::SingleStore) } /// Localhost callback ports to try, in order. PlanetScale accepts only ONE @@ -246,6 +261,8 @@ impl Provider { Self::Nile => nile::list_databases(token).await, Self::Upstash => upstash::list_databases(token).await, Self::PostHog => posthog::list_databases(token).await, + Self::Xata => xata::list_databases(token).await, + Self::SingleStore => singlestore::list_databases(token).await, } } @@ -265,6 +282,8 @@ impl Provider { Self::Nile => nile::build_connection(token, db_ref).await, Self::Upstash => upstash::build_connection(token, db_ref).await, Self::PostHog => posthog::build_connection(token, db_ref).await, + Self::Xata => xata::build_connection(token, db_ref).await, + Self::SingleStore => singlestore::build_connection(token, db_ref).await, } } @@ -279,7 +298,7 @@ impl Provider { Self::Turso => turso::create_options(token, scope).await, Self::Nile => nile::create_options(token, scope).await, Self::Upstash => Ok(upstash::create_options()), - Self::PlanetScale | Self::Railway | Self::PostHog => Err(self.create_unsupported()), + Self::PlanetScale | Self::Railway | Self::PostHog | Self::Xata | Self::SingleStore => Err(self.create_unsupported()), } } @@ -292,7 +311,7 @@ impl Provider { Self::Turso => turso::create_database(token, req).await, Self::Nile => nile::create_database(token, req).await, Self::Upstash => upstash::create_database(token, req).await, - Self::PlanetScale | Self::Railway | Self::PostHog => Err(self.create_unsupported()), + Self::PlanetScale | Self::Railway | Self::PostHog | Self::Xata | Self::SingleStore => Err(self.create_unsupported()), } } @@ -306,7 +325,7 @@ impl Provider { Self::Upstash => upstash::database_status(token, db_ref).await, // Turso databases are usable the moment the create call returns. Self::Turso => Ok(DatabaseStatus::ready("ready")), - Self::PlanetScale | Self::Railway | Self::PostHog => Err(self.create_unsupported()), + Self::PlanetScale | Self::Railway | Self::PostHog | Self::Xata | Self::SingleStore => Err(self.create_unsupported()), } } @@ -323,6 +342,8 @@ impl Provider { // access, and a project created later isn't covered by the grant. Self::Railway => "Stroke's Railway sign-in can only see the projects you shared with it, so it can't create one. Create it in the Railway dashboard, then refresh.".into(), Self::PostHog => "PostHog projects are created in PostHog.".into(), + Self::Xata => "Create Xata projects and branches in the Xata console, then refresh.".into(), + Self::SingleStore => "Create SingleStore workspaces in the SingleStore portal, then refresh.".into(), _ => format!("{} databases can't be created from Stroke yet.", self.label()), } } diff --git a/src-tauri/src/providers/singlestore.rs b/src-tauri/src/providers/singlestore.rs new file mode 100644 index 00000000..bd9e4377 --- /dev/null +++ b/src-tauri/src/providers/singlestore.rs @@ -0,0 +1,153 @@ +/*! + * SingleStore adapter - MySQL wire protocol. Signed in with a Management API + * key (Cloud Portal → Configuration → API keys), sent as `Authorization: + * Bearer`. Lists every workspace in every workspace group, and the free + * starter workspaces. The API never returns a database password, so the + * connection asks for it once (`needs_password`), like Supabase: the workspace + * group's admin password, or the starter workspace's user password. + * + * SingleStore also runs OAuth (authsvc.singlestore.com, PKCE), whose access + * token logs in to the database directly; that needs a client ID registered + * with SingleStore and replaces the key and the password prompt once we have one. + */ + +use super::SendRetry; +use super::{http, OAuthConfig, ProviderConnection, ProviderDatabase}; +use serde_json::Value; + +/// Unused for a key-based provider; present so `Provider::oauth` stays total. +pub const OAUTH: OAuthConfig = OAuthConfig { client_id: "", auth_url: "", token_url: "", scopes: "" }; + +const API: &str = "https://api.singlestore.com/v1"; + +async fn get(token: &str, path: &str, what: &str) -> Result { + let key = token.trim(); + if key.is_empty() { + return Err("SingleStore needs a Management API key.".into()); + } + let resp = http() + .get(format!("{API}{path}")) + .bearer_auth(key) + .send_retrying() + .await + .map_err(|e| format!("SingleStore request failed ({what}): {}", super::describe(&e)))?; + let status = resp.status().as_u16(); + if status == 401 { + return Err(super::UNAUTHORIZED.into()); + } + let text = resp.text().await.map_err(|e| format!("SingleStore read failed: {e}"))?; + if !(200..300).contains(&status) { + let snippet: String = text.chars().take(160).collect(); + return Err(format!("SingleStore API error ({status}) on {what}: {snippet}")); + } + serde_json::from_str(&text).map_err(|_| format!("SingleStore returned a non-JSON response for {what}")) +} + +/// `{ kind: "workspace" | "starter", id }`, what `build_connection` needs. +fn db_ref(kind: &str, id: &str) -> String { + serde_json::json!({ "kind": kind, "id": id }).to_string() +} + +fn active(state: Option<&str>) -> bool { + !matches!(state.map(str::to_ascii_uppercase).as_deref(), Some("TERMINATED") | Some("FAILED")) +} + +pub async fn list_databases(token: &str) -> Result, String> { + let groups = get(token, "/workspaceGroups", "listing workspace groups").await?; + let mut out = Vec::new(); + for g in groups.as_array().into_iter().flatten() { + let Some(gid) = g["workspaceGroupID"].as_str() else { continue }; + if !active(g["state"].as_str()) { + continue; + } + let gname = g["name"].as_str().unwrap_or(gid); + let path = format!("/workspaces?workspaceGroupID={}", urlencoding::encode(gid)); + let ws = get(token, &path, "listing workspaces").await?; + for w in ws.as_array().into_iter().flatten() { + let Some(wid) = w["workspaceID"].as_str() else { continue }; + if !active(w["state"].as_str()) { + continue; + } + out.push(ProviderDatabase { + db_ref: db_ref("workspace", wid), + name: format!("{gname} / {}", w["name"].as_str().unwrap_or(wid)), + region: g["regionName"].as_str().or_else(|| g["region"].as_str()).map(String::from), + kind: Some("Workspace".into()), + host: w["endpoint"].as_str().map(String::from), + }); + } + } + // Starter (free) workspaces live under their own endpoint; an account + // without any, or a key that can't read them, just has none. + if let Ok(starters) = get(token, "/sharedtier/virtualWorkspaces", "listing starter workspaces").await { + for w in starters.as_array().into_iter().flatten() { + let Some(id) = w["virtualWorkspaceID"].as_str() else { continue }; + if !active(w["state"].as_str()) { + continue; + } + out.push(ProviderDatabase { + db_ref: db_ref("starter", id), + name: w["name"].as_str().unwrap_or(id).to_string(), + region: None, + kind: Some("Starter workspace".into()), + host: w["endpoint"].as_str().map(String::from), + }); + } + } + Ok(out) +} + +pub async fn build_connection(token: &str, reference: &str) -> Result { + let r: Value = serde_json::from_str(reference).map_err(|_| "That SingleStore reference is damaged. Refresh the list.".to_string())?; + let id = r["id"].as_str().unwrap_or_default(); + if id.is_empty() { + return Err("That SingleStore reference is incomplete. Refresh the list.".into()); + } + let id_enc = urlencoding::encode(id); + if r["kind"].as_str() == Some("starter") { + let w = get(token, &format!("/sharedtier/virtualWorkspaces/{id_enc}"), "reading the starter workspace").await?; + return connection_from(&w, "starter"); + } + let w = get(token, &format!("/workspaces/{id_enc}"), "reading the workspace").await?; + connection_from(&w, "workspace") +} + +fn connection_from(w: &Value, kind: &str) -> Result { + let name = w["name"].as_str().unwrap_or("SingleStore").to_string(); + let state = w["state"].as_str().unwrap_or("ACTIVE").to_ascii_uppercase(); + if state == "SUSPENDED" { + return Err(format!("{name} is suspended. Resume it in the SingleStore portal, then connect.")); + } + let host = w["endpoint"].as_str().filter(|h| !h.is_empty()).ok_or_else(|| format!("{name} has no endpoint yet. It may still be starting."))?; + let starter = kind == "starter"; + Ok(ProviderConnection { + db_type: "mysql".into(), + host: host.to_string(), + port: w["mysqlDmlPort"].as_u64().and_then(|p| u16::try_from(p).ok()).unwrap_or(3306), + username: if starter { w["username"].as_str().unwrap_or_default().to_string() } else { "admin".into() }, + password: String::new(), + database: w["databaseName"].as_str().unwrap_or_default().to_string(), + // SingleStore's cloud endpoints require TLS. + ssl: true, + needs_password: true, + name: format!("SingleStore · {name}"), + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn workspaces_connect_as_admin_over_tls_and_ask_for_the_password() { + let w = serde_json::json!({ "name": "prod", "state": "ACTIVE", "endpoint": "svc-1.aws.svc.singlestore.com" }); + let c = connection_from(&w, "workspace").unwrap(); + assert_eq!((c.db_type.as_str(), c.port, c.username.as_str()), ("mysql", 3306, "admin")); + assert!(c.ssl && c.needs_password); + let s = serde_json::json!({ "name": "free", "endpoint": "svc-2.aws.svc.singlestore.com", "mysqlDmlPort": 3333, "databaseName": "db_free", "username": "u_1" }); + let c = connection_from(&s, "starter").unwrap(); + assert_eq!((c.port, c.database.as_str(), c.username.as_str()), (3333, "db_free", "u_1")); + assert!(connection_from(&serde_json::json!({ "name": "x", "state": "SUSPENDED", "endpoint": "h" }), "workspace").unwrap_err().contains("suspended")); + assert!(!active(Some("Terminated")) && active(Some("ACTIVE")) && active(None)); + } +} diff --git a/src-tauri/src/providers/xata.rs b/src-tauri/src/providers/xata.rs new file mode 100644 index 00000000..7be01e80 --- /dev/null +++ b/src-tauri/src/providers/xata.rs @@ -0,0 +1,154 @@ +/*! + * Xata adapter - Postgres. Signed in with an API key (Xata console → Account + * or Organization settings → API keys), sent as `Authorization: Bearer`. Lists + * every branch of every project in every organization the key can see, and + * connects with the branch's own credentials (`…/branches/{id}/credentials`), + * which Xata hands out per branch. + * + * Xata also runs OAuth (Keycloak, with dynamic client registration); that sign-in + * can replace the key once its tokens are confirmed to carry `credentials:read`. + */ + +use super::SendRetry; +use super::{http, OAuthConfig, ProviderConnection, ProviderDatabase}; +use serde_json::Value; + +/// Unused for a key-based provider; present so `Provider::oauth` stays total. +pub const OAUTH: OAuthConfig = OAuthConfig { client_id: "", auth_url: "", token_url: "", scopes: "" }; + +const API: &str = "https://api.xata.tech"; + +async fn get(token: &str, path: &str, what: &str) -> Result { + let key = token.trim(); + if key.is_empty() { + return Err("Xata needs an API key.".into()); + } + let resp = http() + .get(format!("{API}{path}")) + .bearer_auth(key) + .send_retrying() + .await + .map_err(|e| format!("Xata request failed ({what}): {}", super::describe(&e)))?; + let status = resp.status().as_u16(); + if status == 401 { + return Err(super::UNAUTHORIZED.into()); + } + let text = resp.text().await.map_err(|e| format!("Xata read failed: {e}"))?; + if status == 403 { + return Err(format!("This Xata API key can't do that ({what}). Use a key with access to the organization's projects and branch credentials.")); + } + if !(200..300).contains(&status) { + let body: Value = serde_json::from_str(&text).unwrap_or(Value::Null); + let msg = body["message"].as_str().map(String::from).unwrap_or_else(|| text.chars().take(160).collect()); + return Err(format!("Xata API error ({status}) on {what}: {msg}")); + } + serde_json::from_str(&text).map_err(|_| format!("Xata returned a non-JSON response for {what}")) +} + +fn enc(s: &str) -> String { + urlencoding::encode(s).into_owned() +} + +/// `{ org, project, branch }`, what `build_connection` needs. +fn db_ref(org: &str, project: &str, branch: &str) -> String { + serde_json::json!({ "org": org, "project": project, "branch": branch }).to_string() +} + +fn ids(body: &Value, list: &str) -> Vec<(String, String)> { + body[list] + .as_array() + .into_iter() + .flatten() + .filter_map(|o| { + let id = o["id"].as_str()?.to_string(); + let name = o["name"].as_str().unwrap_or(&id).to_string(); + Some((id, name)) + }) + .collect() +} + +pub async fn list_databases(token: &str) -> Result, String> { + let orgs = get(token, "/organizations", "listing organizations").await?; + let orgs = ids(&orgs, "organizations"); + let many_orgs = orgs.len() > 1; + let mut out = Vec::new(); + for (org, org_name) in &orgs { + let projects = get(token, &format!("/organizations/{}/projects", enc(org)), "listing projects").await?; + // Every project's branches at once: an account with ten projects + // shouldn't wait for ten round trips in a row. + let fetches = ids(&projects, "projects").into_iter().map(|(project, project_name)| async move { + let path = format!("/organizations/{}/projects/{}/branches", enc(org), enc(&project)); + let branches = get(token, &path, "listing branches").await; + (project, project_name, branches) + }); + for (project, project_name, branches) in futures::future::join_all(fetches).await { + let branches = branches?; + for b in branches["branches"].as_array().into_iter().flatten() { + let Some(branch) = b["id"].as_str() else { continue }; + let branch_name = b["name"].as_str().unwrap_or(branch); + let prefix = if many_orgs { format!("{org_name} / ") } else { String::new() }; + out.push(ProviderDatabase { + db_ref: db_ref(org, &project, branch), + name: format!("{prefix}{project_name} / {branch_name}"), + region: b["region"].as_str().filter(|r| !r.is_empty()).map(String::from), + kind: Some(if b["parentID"].as_str().is_some() { "Branch".into() } else { "Main branch".into() }), + host: None, + }); + } + } + } + Ok(out) +} + +pub async fn build_connection(token: &str, reference: &str) -> Result { + let r: Value = serde_json::from_str(reference).map_err(|_| "That Xata branch reference is damaged. Refresh the list.".to_string())?; + let (org, project, branch) = ( + r["org"].as_str().unwrap_or_default(), + r["project"].as_str().unwrap_or_default(), + r["branch"].as_str().unwrap_or_default(), + ); + if org.is_empty() || project.is_empty() || branch.is_empty() { + return Err("That Xata branch reference is incomplete. Refresh the list.".into()); + } + let path = format!("/organizations/{}/projects/{}/branches/{}/credentials", enc(org), enc(project), enc(branch)); + let c = get(token, &path, "reading the branch credentials").await?; + connection_from_credentials(&c, branch) +} + +fn connection_from_credentials(c: &Value, branch: &str) -> Result { + let host = c["hostname"].as_str().filter(|h| !h.is_empty()).ok_or("Xata returned no host for this branch. It may still be starting.")?; + Ok(ProviderConnection { + db_type: "postgres".into(), + host: host.to_string(), + port: c["port"].as_u64().and_then(|p| u16::try_from(p).ok()).unwrap_or(5432), + username: c["username"].as_str().unwrap_or("xata").to_string(), + password: c["password"].as_str().unwrap_or_default().to_string(), + database: c["dbname"].as_str().unwrap_or("xata").to_string(), + // Xata only accepts TLS. + ssl: true, + needs_password: false, + name: format!("Xata · {branch}"), + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn credentials_become_a_tls_postgres_connection() { + let c = serde_json::json!({ "username": "xata", "password": "p", "hostname": "us-east-1.xata.tech", "port": 5432, "dbname": "app", "connectionString": "postgresql://…" }); + let conn = connection_from_credentials(&c, "main").unwrap(); + assert_eq!((conn.db_type.as_str(), conn.host.as_str(), conn.port, conn.database.as_str()), ("postgres", "us-east-1.xata.tech", 5432, "app")); + assert!(conn.ssl && !conn.needs_password); + assert!(connection_from_credentials(&serde_json::json!({}), "main").is_err()); + } + + #[test] + fn list_ids_read_name_and_id() { + let body = serde_json::json!({ "projects": [{ "id": "p1", "name": "Shop" }, { "id": "p2" }, { "name": "no id" }] }); + assert_eq!(ids(&body, "projects"), vec![("p1".into(), "Shop".into()), ("p2".into(), "p2".into())]); + let r: Value = serde_json::from_str(&db_ref("o", "p", "b")).unwrap(); + assert_eq!(r["branch"], "b"); + } +} diff --git a/src/lib/connection-provider.js b/src/lib/connection-provider.js index a2f1c22b..6d46ddf1 100644 --- a/src/lib/connection-provider.js +++ b/src/lib/connection-provider.js @@ -18,6 +18,8 @@ const HOSTS = [ [/(\.rlwy\.net|\.railway\.app|\.railway\.internal)$/i, 'railway'], [/\.thenile\.dev$/i, 'nile'], [/\.upstash\.io$/i, 'upstash'], + [/\.xata\.tech$/i, 'xata'], + [/\.svc\.singlestore\.com$/i, 'singlestore'], ] /** Older saved connections used these ids before the cards settled on theirs. */ diff --git a/src/lib/db-icons.js b/src/lib/db-icons.js index 40436af0..d8f80512 100644 --- a/src/lib/db-icons.js +++ b/src/lib/db-icons.js @@ -29,6 +29,9 @@ export const BRAND_MARKS = { // paths left of the wordmark). nile: { d: 'M20.121 21.658C14.5515 21.0013 9.75863 17.4158 7.56726 12.2611C6.97966 10.8371 5.56944 9.83472 3.93571 9.83472C1.76277 9.83472 0 11.5975 0 13.7681C0 14.8534 0.437813 15.8397 1.15214 16.5494C2.87113 18.2684 2.87113 21.0635 1.15214 22.7825C0.444726 23.4899 0 24.4784 0 25.5637C0 27.7344 1.76277 29.4971 3.93341 29.4971C6.10404 29.4971 7.86681 27.7344 7.86681 25.5637C7.86681 24.4784 7.429 23.4922 6.71467 22.7825C5.44962 21.5174 5.11781 19.6694 5.71231 18.1025C10.3093 19.3376 14.1368 22.6166 16.0286 27.0707C16.6162 28.4948 18.0264 29.4971 19.6601 29.4971C21.8307 29.4971 23.5935 27.7344 23.5935 25.5637C23.5935 23.5452 22.0704 21.8861 20.1187 21.6603L20.121 21.658ZM22.4414 6.71467C23.1488 6.00726 23.5935 5.01872 23.5935 3.93341C23.5935 1.76277 21.8307 0 19.6601 0C17.4895 0 15.7267 1.76277 15.7267 3.93341C15.7267 5.01872 16.1645 6.00495 16.8789 6.71467C18.1439 7.97972 18.4757 9.82775 17.8812 11.3947C13.2842 10.1596 9.45677 6.88058 7.56495 2.42641C6.97736 1.00236 5.56944 0 3.93341 0C1.76277 0 0 1.76277 0 3.93341C0 5.95196 1.52313 7.61104 3.47485 7.83686C9.0443 8.48436 13.828 12.0721 16.0217 17.2268C16.6092 18.6508 18.0195 19.6532 19.6532 19.6532C21.8238 19.6532 23.5866 17.8904 23.5866 15.7198C23.5866 14.6345 23.1488 13.6483 22.4345 12.9385C20.7247 11.2288 20.7247 8.44058 22.4414 6.71467Z', hex: '#8A63F9', vb: '0 2 28 26' }, docker: { d: 'M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z', hex: '#2496ED' }, + singlestore: { d: 'M17.029 5.063c-.914-1.916-2.8-3.432-5.114-4.033C11.4.887 10.858.83 10.258.8c-.886 0-1.743.114-2.629.343-2.2.658-3.742 1.945-4.657 2.947C1.801 5.435 1.03 6.837.572 8.238c0 .029-.028.057-.028.115C.515 8.467.4 8.81.4 8.896c-.029.057-.029.143-.057.2l-.086.344c0 .028 0 .057-.028.086-.743 3.69.49 7.001 1.234 8.231.185.308.338.564.49.8C.27 9.403 5.116 5.035 10.63 4.92c2.886-.057 5.771 1.116 7.171 3.461-.086-1.287-.171-2.002-.771-3.318zM12.543 0c2.572.715 4.914 2.517 5.886 4.72 1.485 3.575 1.143 8.095-.486 10.784-1.371 2.203-3.485 3.375-5.914 3.347-3.771-.029-6.828-3.032-6.857-6.808 0-3.776 2.971-6.894 6.857-6.894.629 0 1.535.087 2.563.516 0 0-.739-.438-2.638-.732C6.497 4.218.058 8.353 1.544 17.878c2.057 3.662 6 6.15 10.485 6.122 6.6-.029 12-5.435 11.97-12.072C24 5.578 18.83.172 12.544 0z', hex: '#AA00FF' }, + // Xata has no simple-icons mark: its X, drawn on the same 24 grid. + xata: { d: 'M3.5 3.5h3.3l5.2 6.4 5.2-6.4h3.3l-6.85 8.5 6.85 8.5h-3.3L12 14.1l-5.2 6.4H3.5l6.85-8.5z', hex: '#F46CAF' }, posthog: { d: 'M9.854 14.5 5 9.647.854 5.5A.5.5 0 0 0 0 5.854V8.44a.5.5 0 0 0 .146.353L5 13.647l.147.146L9.854 18.5l.146.147v-.049c.065.03.134.049.207.049h2.586a.5.5 0 0 0 .353-.854L9.854 14.5zm0-5-4-4a.487.487 0 0 0-.409-.144.515.515 0 0 0-.356.21.493.493 0 0 0-.089.288V8.44a.5.5 0 0 0 .147.353l9 9a.5.5 0 0 0 .853-.354v-2.585a.5.5 0 0 0-.146-.354l-5-5zm1-4a.5.5 0 0 0-.854.354V8.44a.5.5 0 0 0 .147.353l4 4a.5.5 0 0 0 .853-.354V9.854a.5.5 0 0 0-.146-.354l-4-4zm12.647 11.515a3.863 3.863 0 0 1-2.232-1.1l-4.708-4.707a.5.5 0 0 0-.854.354v6.585a.5.5 0 0 0 .5.5H23.5a.5.5 0 0 0 .5-.5v-.6c0-.276-.225-.497-.499-.532zm-5.394.032a.8.8 0 1 1 0-1.6.8.8 0 0 1 0 1.6zM.854 15.5a.5.5 0 0 0-.854.354v2.293a.5.5 0 0 0 .5.5h2.293c.222 0 .39-.135.462-.309a.493.493 0 0 0-.109-.545L.854 15.501zM5 14.647.854 10.5a.5.5 0 0 0-.854.353v2.586a.5.5 0 0 0 .146.353L4.854 18.5l.146.147h2.793a.5.5 0 0 0 .353-.854L5 14.647z', hex: '#F9BD2B' }, turso: { d: 'm23.31.803-.563-.42-1.11 1.189-.891-1.286-.512.235.704 1.798-.326.35L18.082 0l-.574.284 2.25 4.836-2.108.741h-.05l-1.143-1.359-1.144 1.36H8.687l-1.144-1.36-1.146 1.363H6.36l-2.12-.745L6.491.284 5.919 0l-2.53 2.668-.327-.349.705-1.798-.512-.236-.89 1.287L1.253.382.69.804 2.42 3.69l-.89.939.311 2.375 2.061.787L3.9 8.817H1.947v.444l.755 1.078 1.197.433v6.971l3.057 4.55L7.657 24l1.101-1.606L9.9 24l.999-1.606L12 24l1.102-1.606L14.1 24l1.141-1.606L16.343 24l.701-1.706 3.058-4.55v-6.972l1.196-.433.756-1.078v-.444h-1.952l.003-1.03 2.054-.784.311-2.375-.89-.939zm-8.93 18.718H8.033l.793-1.615.794 1.615.793-1.083.793 1.083.794-1.083.793 1.083.794-1.083.793 1.083.793-1.615.794 1.615zm3.886-7.39-3.3 1.084-.143 3.061-2.827.627-2.826-.627-.142-3.06-3.3-1.085v-1.635l4.266 1.21-.052 4.126h4.109l-.052-4.127 4.266-1.209z', hex: '#4FF8D2' }, mssql: { d: 'M12 2C7.03 2 3 3.34 3 5v14c0 1.66 4.03 3 9 3s9-1.34 9-3V5c0-1.66-4.03-3-9-3zm7 17c0 .3-2.54 1.5-7 1.5S5 19.3 5 19v-2.23c1.61.74 4.19 1.23 7 1.23s5.39-.49 7-1.23V19zm0-5c0 .3-2.54 1.5-7 1.5S5 14.3 5 14v-2.23c1.61.74 4.19 1.23 7 1.23s5.39-.49 7-1.23V14zM12 8.5C7.54 8.5 5 7.3 5 7s2.54-1.5 7-1.5 7 1.2 7 1.5-2.54 1.5-7 1.5z', hex: '#CC2927' }, diff --git a/src/lib/providers.js b/src/lib/providers.js index dc9b70f5..9eabed3f 100644 --- a/src/lib/providers.js +++ b/src/lib/providers.js @@ -39,6 +39,30 @@ export const PROVIDERS = [ join: (/** @type {Record} */ v) => `${v.email.trim()}:${v.apiKey.trim()}`, }, }, + { + id: 'xata', name: 'Xata', mode: 'token', engine: 'postgres', + blurb: 'Postgres with copy-on-write branches, every branch listed', + token: { + help: 'Create an API key in the Xata console under your account or organization settings, API keys.', + helpUrl: 'https://console.xata.io', + fields: [ + { key: 'apiKey', label: 'API key', type: 'password', autocomplete: 'off', placeholder: 'xau_…', mono: true }, + ], + join: (/** @type {Record} */ v) => v.apiKey.trim(), + }, + }, + { + id: 'singlestore', name: 'SingleStore', mode: 'token', engine: 'mysql', + blurb: 'Workspaces and free starter workspaces, asks for the database password once', + token: { + help: 'Create a Management API key in the SingleStore portal under Configuration, API keys.', + helpUrl: 'https://portal.singlestore.com', + fields: [ + { key: 'apiKey', label: 'Management API key', type: 'password', autocomplete: 'off', placeholder: 'API key', mono: true }, + ], + join: (/** @type {Record} */ v) => v.apiKey.trim(), + }, + }, { id: 'posthog', name: 'PostHog', mode: 'token', engine: 'posthog', blurb: 'Product analytics, queried with HogQL. Read-only', diff --git a/src/lib/stores/connections.js b/src/lib/stores/connections.js index 0557dfd1..af3ed4fe 100644 --- a/src/lib/stores/connections.js +++ b/src/lib/stores/connections.js @@ -49,7 +49,7 @@ const DISCONNECTED_KEY = 'stroke:disconnected' * ssh?: SshConfig * readOnly?: boolean * environment?: 'prod' | 'staging' | 'dev' | null - * provider?: 'neon' | 'supabase' | 'planetscale' | 'prisma' | 'tidb' | 'turso' | 'nile' | 'railway' | 'upstash' | 'posthog' + * provider?: 'neon' | 'supabase' | 'planetscale' | 'prisma' | 'tidb' | 'turso' | 'nile' | 'railway' | 'upstash' | 'posthog' | 'xata' | 'singlestore' * projectId?: string - PostHog project * apiKey?: string - PostHog personal API key * providerRef?: string - the provider's own id for this database (its db_ref), so reopening it from the provider picker connects with this entry instead of minting new credentials