Skip to content

feat(azure): add databases and split Cosmos NoSQL#149

Open
thomhurst wants to merge 7 commits into
floci-io:mainfrom
thomhurst:agent/azure-sql
Open

feat(azure): add databases and split Cosmos NoSQL#149
thomhurst wants to merge 7 commits into
floci-io:mainfrom
thomhurst:agent/azure-sql

Conversation

@thomhurst

@thomhurst thomhurst commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • add Azure SQL Database and PostgreSQL Flexible Server adapters through the Floci-AZ ARM management-plane contracts
  • expose database, schema/table, row-preview, and SQL query workflows through the shared relational explorer
  • keep credentials page/request-scoped and connect to local engines over TDS or the PostgreSQL wire protocol
  • move Cosmos DB NoSQL into a separate schema-driven nosql service and navigation entry
  • preserve Cosmos database, container, document, and SQL query workflows under /api/clouds/:cloud/services/nosql
  • add provider NoSQL schemas for Azure Cosmos DB NoSQL, Amazon DynamoDB, and Google Firestore

Closes #92
Refs #67
Refs floci-io/floci-az#138

Validation

  • pnpm lint
  • pnpm type-check
  • pnpm test — 171 passed in the API container
  • pnpm build
  • manually verified Azure SQL Server and PostgreSQL Flexible Server lifecycle and data-plane queries against Floci-AZ at :4577
  • manually verified database/table exploration, dialect-aware table previews, typed result grids, and horizontal overflow in headed Chrome

Notes

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-alpine sidecar and does not require EULA acceptance.

Cosmos:
image
image

SQL:
image
image

Preserve Cosmos DB while exposing Azure SQL servers through the shared database service.\n\nCloses floci-io#92
@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown

Greptile Summary

This PR splits the monolithic Azure database service into two distinct services: a relational database service (covering Azure SQL Database and Azure Database for PostgreSQL via new AzureSqlAdapter and AzurePostgresAdapter) and a dedicated nosql service (Cosmos DB NoSQL, migrated from the old database route). It also adds a full SQL data-plane explorer panel in the frontend with connection, database/table browsing, and query execution.

  • New adapters: AzureSqlAdapter and AzurePostgresAdapter handle ARM management-plane CRUD and data-plane queries via mssql and pg respectively; AzureDatabaseAdapter now orchestrates them as sub-adapters, routing by resource ID prefix or connection.engine.
  • Cosmos split: All /database/resources/:id/containers* routes are moved to /nosql/resources/:id/containers*, and AzureNoSqlAdapter is registered separately under nosql — isolating Cosmos failures from SQL listing.
  • Frontend: AzureSqlPanel provides a three-pane SQL explorer (databases, tables, query editor) rendered for sql-server and postgres-flexible-server resource types; the nosql service continues to show CosmosNoSqlPanel.

Confidence Score: 5/5

Safe to merge. The refactor correctly isolates Cosmos NoSQL from relational databases, the adapter routing logic is sound, and data-plane connections are properly cleaned up.

The Cosmos/SQL split is well-structured: route migration is complete and symmetric, the AzureDatabaseAdapter sub-adapter dispatch (by ID prefix and connection.engine) is correct, and previously flagged issues (withApiVersion separator, Cosmos failure blocking SQL) are fully resolved. Both new data clients create and close connections within each request. Tests cover the core adapter behaviour. No logic errors were found in the changed paths.

No files require special attention.

Important Files Changed

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[]
Loading
%%{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[]
Loading

Reviews (6): Last reviewed commit: "feat(azure): support PostgreSQL explorer" | Re-trigger Greptile

Comment thread packages/api/src/adapter-azure/AzureDatabaseAdapter.ts Outdated
Comment thread packages/api/src/adapter-azure/AzureSqlAdapter.ts
@thomhurst thomhurst changed the title feat(azure): add SQL to Cloud Explorer feat(azure): add SQL and split Cosmos NoSQL Jul 18, 2026
@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

@thomhurst
thomhurst requested a review from hectorvent as a code owner July 18, 2026 20:49
@thomhurst thomhurst changed the title feat(azure): add SQL and split Cosmos NoSQL feat(azure): add databases and split Cosmos NoSQL Jul 18, 2026
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.

feat(azure): Azure SQL in Cloud Explorer

1 participant