feat(azure): add databases and split Cosmos NoSQL#149
Conversation
Preserve Cosmos DB while exposing Azure SQL servers through the shared database service.\n\nCloses floci-io#92
|
| Filename | Overview |
|---|---|
| packages/api/src/adapter-azure/AzureDatabaseAdapter.ts | Refactored from a monolithic Cosmos adapter into a thin orchestrator that routes list/get/create/delete and SQL data-plane operations to AzureSqlAdapter or AzurePostgresAdapter based on resource ID prefix or connection.engine. |
| packages/api/src/adapter-azure/AzureSqlAdapter.ts | New adapter for Azure SQL Database; handles ARM management-plane CRUD and T-SQL data-plane queries via MssqlDataClient. withApiVersion correctly uses ? vs & separator. Internal sub-adapter; not registered directly. |
| packages/api/src/adapter-azure/AzurePostgresAdapter.ts | New adapter for Azure Database for PostgreSQL Flexible Servers; mirrors AzureSqlAdapter structure with pg-specific queries and PostgresDataClient. Correct withApiVersion separator handling. |
| packages/api/src/adapter-azure/AzureNoSqlAdapter.ts | Cosmos DB NoSQL logic extracted from the old AzureDatabaseAdapter unchanged, now registered under the nosql service. fetchWithFallbacks routing and all Cosmos operations are intact. |
| packages/api/src/adapter-azure/MssqlDataClient.ts | New data-plane client for SQL Server using mssql; creates a single-connection pool per query, cleans up in finally, caps result sets at 500 rows, and normalizes column types via sqlTypeName. |
| packages/api/src/adapter-azure/PostgresDataClient.ts | New data-plane client for PostgreSQL using pg; single Client per query, handles multi-statement results, maps OID type codes to names, caps at 500 rows. |
| packages/api/src/routes/clouds.ts | Cosmos container/item/query routes moved from /database to /nosql; three new POST routes added for SQL database listing, table listing, and query execution under /database. isServiceType updated to include nosql. |
| packages/frontend/src/components/AzureSqlPanel.tsx | New 436-line SQL explorer panel supporting both Azure SQL and PostgreSQL engines. Handles connect/disconnect, database selection, table preview, and query editor with proper state reset on resource change. |
| packages/api/src/cloud-spi/noSqlSchema.ts | New schema file providing awsNoSqlSchema (DynamoDB), azureNoSqlSchema (Cosmos DB NoSQL), and gcpNoSqlSchema (Firestore) with appropriate fields, actions, and capabilities. |
| packages/frontend/src/api/cloudProxyClient.ts | Cosmos endpoint keys updated from clouds.database.cosmos to clouds.nosql.cosmos; three new functions added for listSqlDatabases, listSqlTables, and querySql with 45s timeout for data-plane calls. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant FE as Frontend (AzureSqlPanel)
participant API as Hono API (/clouds/:cloud/services/database)
participant DB as AzureDatabaseAdapter
participant SQL as AzureSqlAdapter
participant PG as AzurePostgresAdapter
participant AZ as Floci-AZ (:4577)
participant MSSQL as SQL Server (data plane)
participant PGDB as PostgreSQL (data plane)
FE->>API: "POST /database/resources/:id/sql/databases {engine, username, password}"
API->>DB: listSqlDatabases(serverId, connection)
DB->>DB: dataAdapter(serverId, connection.engine)
alt "engine=azure-sql or sql-server: prefix"
DB->>SQL: listSqlDatabases(serverId, connection)
SQL->>AZ: "GET /subscriptions/.../servers/{name}?api-version=..."
AZ-->>SQL: server metadata (FQDN, port)
SQL->>MSSQL: SELECT FROM sys.databases (master)
MSSQL-->>SQL: database list
SQL-->>DB: SqlDatabase[]
else "engine=postgresql or postgres-flexible-server: prefix"
DB->>PG: listSqlDatabases(serverId, connection)
PG->>AZ: "GET /subscriptions/.../flexibleServers/{name}?api-version=..."
AZ-->>PG: server metadata (FQDN, port)
PG->>PGDB: SELECT FROM pg_database
PGDB-->>PG: database list
PG-->>DB: SqlDatabase[]
end
DB-->>API: SqlDatabase[]
API-->>FE: JSON SqlDatabase[]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant FE as Frontend (AzureSqlPanel)
participant API as Hono API (/clouds/:cloud/services/database)
participant DB as AzureDatabaseAdapter
participant SQL as AzureSqlAdapter
participant PG as AzurePostgresAdapter
participant AZ as Floci-AZ (:4577)
participant MSSQL as SQL Server (data plane)
participant PGDB as PostgreSQL (data plane)
FE->>API: "POST /database/resources/:id/sql/databases {engine, username, password}"
API->>DB: listSqlDatabases(serverId, connection)
DB->>DB: dataAdapter(serverId, connection.engine)
alt "engine=azure-sql or sql-server: prefix"
DB->>SQL: listSqlDatabases(serverId, connection)
SQL->>AZ: "GET /subscriptions/.../servers/{name}?api-version=..."
AZ-->>SQL: server metadata (FQDN, port)
SQL->>MSSQL: SELECT FROM sys.databases (master)
MSSQL-->>SQL: database list
SQL-->>DB: SqlDatabase[]
else "engine=postgresql or postgres-flexible-server: prefix"
DB->>PG: listSqlDatabases(serverId, connection)
PG->>AZ: "GET /subscriptions/.../flexibleServers/{name}?api-version=..."
AZ-->>PG: server metadata (FQDN, port)
PG->>PGDB: SELECT FROM pg_database
PGDB-->>PG: database list
PG-->>DB: SqlDatabase[]
end
DB-->>API: SqlDatabase[]
API-->>FE: JSON SqlDatabase[]
Reviews (6): Last reviewed commit: "feat(azure): support PostgreSQL explorer" | Re-trigger Greptile
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
First-time provisioning can pull a 2.29 GB SQL engine image and take several minutes.\n\nRefs floci-io/floci-az#138
Summary
nosqlservice and navigation entry/api/clouds/:cloud/services/nosqlCloses #92
Refs #67
Refs floci-io/floci-az#138
Validation
pnpm lintpnpm type-checkpnpm test— 171 passed in the API containerpnpm build:4577Notes
Azure SQL server creation follows Floci-AZ runtime configuration: a real data-plane container requires explicit SQL Server EULA acceptance. First provisioning can pull the SQL Edge image; database creates therefore allow five minutes.
PostgreSQL Flexible Server uses Floci-AZ's real
postgres:17-alpinesidecar and does not require EULA acceptance.Cosmos:


SQL:

