Format non-SQL driver queries as JSON in the query preview

Merged
GR
7d ago
+2094-59

The query preview formats the recorded query with sql-formatter, using the connection driver as the dialect. Drivers that do not speak SQL, MongoDB being one, record their commands as JSON. Feeding that to sql-formatter throws Parse error: Unexpected "{ "find" :", so the query detail panel never renders and the entry is unusable.

The formatter and the highlight language are now resolved from the connection driver. A driver that maps to a known SQL dialect is formatted as before. Any other driver is pretty printed as JSON and highlighted with the json grammar. The pgsql and sqlsrv aliases keep their current behaviour, and a driver that matches neither is returned untouched.

The dashboard assets had no test setup, so the second commit adds Vitest with jsdom, a workflow to run it, and a suite covering the query preview: the dialect resolution, the driver aliases, the JSON pretty printing, the value passed to the clipboard, and the highlight applied once the entry is ready.

Vitest is held at 3.2.7 because the assets build with Vite 5, and Vitest 4 and later require Vite 6 or newer.

image