sqlite-hub 0.12.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +118 -23
  2. package/bin/sqlite-hub.js +1041 -224
  3. package/frontend/index.html +1 -0
  4. package/frontend/js/api.js +32 -2
  5. package/frontend/js/app.js +989 -13
  6. package/frontend/js/components/modal.js +644 -15
  7. package/frontend/js/components/pageHeader.js +14 -16
  8. package/frontend/js/components/queryEditor.js +9 -1
  9. package/frontend/js/components/queryHistoryPanel.js +126 -131
  10. package/frontend/js/components/queryResults.js +79 -17
  11. package/frontend/js/components/rowEditorPanel.js +204 -10
  12. package/frontend/js/components/sidebar.js +102 -18
  13. package/frontend/js/components/tableDesignerEditor.js +69 -11
  14. package/frontend/js/router.js +8 -0
  15. package/frontend/js/store.js +868 -9
  16. package/frontend/js/utils/copyColumnExport.js +117 -0
  17. package/frontend/js/utils/exportFilenames.js +32 -0
  18. package/frontend/js/utils/filePathPreview.js +315 -0
  19. package/frontend/js/utils/format.js +1 -1
  20. package/frontend/js/utils/markdownDocuments.js +248 -0
  21. package/frontend/js/utils/rowEditorJson.js +65 -0
  22. package/frontend/js/utils/sqlFormatter.js +691 -0
  23. package/frontend/js/utils/tableDesigner.js +178 -6
  24. package/frontend/js/utils/textCellStats.js +20 -0
  25. package/frontend/js/utils/timestampPreview.js +264 -0
  26. package/frontend/js/views/charts.js +3 -1
  27. package/frontend/js/views/data.js +34 -2
  28. package/frontend/js/views/documents.js +300 -0
  29. package/frontend/js/views/editor.js +48 -1
  30. package/frontend/js/views/settings.js +39 -6
  31. package/frontend/js/views/structure.js +154 -212
  32. package/frontend/styles/base.css +6 -0
  33. package/frontend/styles/components.css +476 -2
  34. package/frontend/styles/structure-graph.css +0 -3
  35. package/frontend/styles/tailwind.generated.css +1 -1
  36. package/frontend/styles/tokens.css +1 -1
  37. package/frontend/styles/views.css +422 -0
  38. package/package.json +3 -3
  39. package/server/routes/documents.js +163 -0
  40. package/server/routes/settings.js +22 -6
  41. package/server/server.js +6 -0
  42. package/server/services/sqlite/introspection.js +10 -0
  43. package/server/services/sqlite/sqlExecutor.js +29 -0
  44. package/server/services/sqlite/tableDesigner/changeAnalysis.js +25 -1
  45. package/server/services/sqlite/tableDesigner/schemaMapping.js +105 -10
  46. package/server/services/sqlite/tableDesigner/validation.js +60 -2
  47. package/server/services/sqlite/tableDesignerService.js +1 -1
  48. package/server/services/storage/appStateStore.js +313 -0
  49. package/tests/check-constraint-options.test.js +14 -0
  50. package/tests/cli-args.test.js +100 -0
  51. package/tests/copy-column-modal.test.js +83 -0
  52. package/tests/database-documents.test.js +85 -0
  53. package/tests/export-filenames.test.js +34 -0
  54. package/tests/file-path-preview.test.js +165 -0
  55. package/tests/markdown-documents.test.js +79 -0
  56. package/tests/row-editor-json.test.js +82 -0
  57. package/tests/row-editor-timestamp-preview.test.js +192 -0
  58. package/tests/settings-metadata.test.js +16 -0
  59. package/tests/settings-view.test.js +32 -0
  60. package/tests/sql-formatter.test.js +173 -0
  61. package/tests/sql-highlight.test.js +38 -0
  62. package/tests/table-designer-v2-unique-constraints.test.js +78 -0
  63. package/tests/text-cell-stats.test.js +38 -0
  64. package/fill.js +0 -526
package/README.md CHANGED
@@ -16,9 +16,12 @@ SQLite Hub keeps that workflow sharp:
16
16
  - filter, sort, page through, and export table data
17
17
  - inspect schema, structure, and relationships
18
18
  - edit records in place with an SQL diff preview before saving
19
- - export tables and query results as CSV, TSV, Markdown, duplicate as table
19
+ - export tables and query results as CSV, TSV, Markdown, or duplicate them as a table
20
+ - copy result columns with formatting, headers, first-10 previews, TXT export, and Markdown todo export
21
+ - keep database-scoped Markdown documents with previews, autosave, imports, exports, and saved-query inserts
22
+ - switch between recent databases with sidebar quick picks
20
23
  - create simple local backups of the active database
21
- - run SQL in a syntax-highlighted editor with history, messages, and performance metrics
24
+ - run and format SQL in a syntax-highlighted editor with history, messages, and performance metrics
22
25
  - turn query-history results into local charts
23
26
  - create and edit tables with a live SQL preview
24
27
  - stay local and move fast
@@ -35,7 +38,7 @@ Inspect tables, columns, types, indexes, foreign keys, and schema details withou
35
38
 
36
39
  ![](./frontend/assets/mockups/data.png)
37
40
 
38
- Scan rows, sort fast, move through local data quickly, and export full tables as CSV. The Data browser supports table search, page sizes up to 250 rows, and advanced filters with column/operator/value controls. Text filters support case-insensitive `contains`, `not contains`, and exact `equals` matching.
41
+ Scan rows, sort fast, move through local data quickly, and export full tables as CSV, TSV, or Markdown. The Data browser also supports duplicating exports as a new table, table search, page sizes up to 250 rows, and advanced filters with column/operator/value controls. Text filters support case-insensitive `contains`, `not contains`, and exact `equals` matching.
39
42
 
40
43
  ### Row editing
41
44
 
@@ -47,7 +50,9 @@ Open one record, edit it in place, preview the SQL diff, then commit. SQLite Hub
47
50
 
48
51
  ![](./frontend/assets/mockups/sql_editor.png)
49
52
 
50
- Write queries in a syntax-highlighted editor, inspect results in the same workflow, and export result sets as CSV. Query drafts survive reloads, query history can be searched and saved, and direct single-table `SELECT` results can be edited from the result grid.
53
+ Write queries in a syntax-highlighted editor, format SQL with the editor Format button, inspect results in the same workflow, and export result sets as CSV, TSV, Markdown, or duplicate them as a table. Query drafts survive reloads, query history can be searched and saved, and direct single-table `SELECT` results can be edited from the result grid.
54
+
55
+ Result column menus include copy actions for a full column, a column with header, or the first 10 values. The same modal can preview the output, copy it, export it as TXT, or turn a column into Markdown todo items.
51
56
 
52
57
  The bottom panel keeps separate tabs for:
53
58
 
@@ -61,6 +66,16 @@ Potentially destructive statements are tracked in query history, and SQLite Hub
61
66
 
62
67
  SQLite Hub stores query history per database. You can search SQL, titles, and notes; mark useful queries as saved; re-run previous queries; and execute saved queries from the CLI.
63
68
 
69
+ ### Documents
70
+
71
+ Documents are local Markdown notes scoped to the active database. SQLite Hub creates a document folder per database, keeps the sidebar fixed while the editor and preview panes scroll independently, and autosaves changes after a short debounce. You can create, rename, delete, import `.md` files, export the current document as Markdown, and toggle the editor or preview pane as needed.
72
+
73
+ The preview supports regular Markdown, ordered and unordered lists, tables, code blocks, links, and clickable task-list checkboxes. Documents can also pull context from saved SQL Editor queries:
74
+
75
+ - Insert Table opens a saved-query picker and inserts that query's result using the same Markdown table export logic as the SQL Editor.
76
+ - Insert Note opens saved queries that have notes and inserts the selected note directly into the document.
77
+ - Markdown Todo column exports from query results can create a new document without embedding the original SQL query.
78
+
64
79
  ### Charts
65
80
 
66
81
  Create charts from chartable `SELECT` query-history entries. Charts can be saved per query, reopened later, and rendered from live query results.
@@ -77,6 +92,10 @@ Configure a media table, tag table, and mapping table, then work through a taggi
77
92
 
78
93
  SQLite Hub remembers common workspace preferences in local storage, including hidden panels, selected editor tabs, query drafts, chart panels, table row size, and Table Designer preview visibility.
79
94
 
95
+ ### Database quick picks
96
+
97
+ The active database footer in the sidebar opens a quick-pick panel with the five most recent databases, so you can switch databases without going back to the Connections view.
98
+
80
99
  ### Simple backups
81
100
 
82
101
  Create timestamped local backups of the active SQLite database in one click. Backups are stored as plain file copies in a local `backups` folder next to the database.
@@ -115,6 +134,8 @@ SQLite Hub ships with a built-in CLI that lets you start the app or query inform
115
134
  ```bash
116
135
  sqlite-hub # start on default port 4173
117
136
  sqlite-hub --port:4174 # start on a custom port
137
+ sqlite-hub --open # open SQLite Hub in the browser
138
+ sqlite-hub --config # show port, URL, app version, and SQLite version
118
139
  sqlite-hub --help # show help text
119
140
  sqlite-hub --version # show version number
120
141
  ```
@@ -139,49 +160,123 @@ Shows an overview of all databases that have been opened in SQLite Hub, includin
139
160
  Retrieve details about a single database by its name (case-insensitive):
140
161
 
141
162
  ```bash
142
- sqlite-hub --database-path:Billly # get the file path
143
- sqlite-hub --database-size:Billly # get the file size (human-readable)
144
- sqlite-hub --database-lastopened:Billly # get last opened timestamp
163
+ sqlite-hub --database:Billly --path # get the file path
164
+ sqlite-hub --database:Billly --size # get the file size
165
+ sqlite-hub --database:Billly --lastopened # get last opened timestamp
145
166
  ```
146
167
 
147
168
  ### List all tables in a database
148
169
 
149
170
  ```bash
150
- sqlite-hub --database-tables:Billly
171
+ sqlite-hub --database:Billly --tables
151
172
  ```
152
173
 
153
174
  Opens the database in read-only mode and prints all table names, sorted alphabetically.
154
175
 
176
+ ### Inspect a table
177
+
178
+ ```bash
179
+ sqlite-hub --database:Billly --table:companies
180
+ ```
181
+
182
+ Prints table metadata such as columns, primary keys, foreign keys, indexes, row count, and row identity strategy.
183
+
155
184
  ### SQL Editor - Saved Queries
156
185
 
157
186
  List all saved queries for a database:
158
187
 
159
188
  ```bash
160
- sqlite-hub --database:Unit-00 --sqleditor
189
+ sqlite-hub --database:Unit-00 --queries
161
190
  ```
162
191
 
163
192
  Execute a specific saved query by name:
164
193
 
165
194
  ```bash
166
- sqlite-hub --database:Unit-00 --sqleditor:"15min Posting Buckets without id 96"
195
+ sqlite-hub --database:Unit-00 --execute:"15min Posting Buckets without id 96"
167
196
  ```
168
197
 
169
198
  This searches the query history for the given database, finds the matching saved query by title, executes it, and returns all results with metadata (row count, columns, timing, and data).
170
199
 
200
+ Show the saved query SQL without executing it:
201
+
202
+ ```bash
203
+ sqlite-hub --database:Unit-00 --query:"Stock Winners"
204
+ ```
205
+
206
+ Show the saved notes for a query:
207
+
208
+ ```bash
209
+ sqlite-hub --database:Unit-00 --notes:"TOP25 Loser and Winner EOD, T1, T3, T5"
210
+ ```
211
+
212
+ Export a saved query using the same CSV, TSV, and Markdown export logic as the SQL Editor:
213
+
214
+ ```bash
215
+ sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:csv
216
+ sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:tsv
217
+ sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:md
218
+ ```
219
+
220
+ The export is written to the current working directory using the generated query export filename.
221
+
222
+ ### Documents CLI
223
+
224
+ List all Markdown documents stored for a database:
225
+
226
+ ```bash
227
+ sqlite-hub --database:Unit-00 --documents
228
+ ```
229
+
230
+ Print one document's Markdown content:
231
+
232
+ ```bash
233
+ sqlite-hub --database:Unit-00 --documents:"Research Notes"
234
+ ```
235
+
236
+ Export one document as a `.md` file into the current working directory:
237
+
238
+ ```bash
239
+ sqlite-hub --database:Unit-00 --documents:"Research Notes" --export
240
+ sqlite-hub --database:Unit-00 --documents:"Research Notes--export"
241
+ ```
242
+
243
+ Documents can be matched by id, filename, title, or a partial filename/title match.
244
+
245
+ ### Row JSON export
246
+
247
+ Export a single row as JSON by primary key or rowid, using the same row-shaping logic as the Row Editor:
248
+
249
+ ```bash
250
+ sqlite-hub --database:Unit-00 --table:companies --export:0a754aba373d34972998792a0be4333c
251
+ ```
252
+
171
253
  ### Available flags
172
254
 
173
- | Flag | Description |
174
- | ------------------------------------- | ------------------------------------- |
175
- | `--help`, `-h` | Show help text |
176
- | `--version`, `-v` | Show version number |
177
- | `--port:PORT` | Start the server on a custom port |
178
- | `--database`, `-d` | List all imported databases |
179
- | `--database-path:name` | Get the file path of a database |
180
- | `--database-size:name` | Get the size of a database |
181
- | `--database-lastopened:name` | Get the last opened timestamp |
182
- | `--database-tables:name` | Get all table names from a database |
183
- | `--database:name --sqleditor` | List all saved queries for a database |
184
- | `--database:name --sqleditor:"query"` | Execute a saved query by name |
255
+ | Flag | Description |
256
+ | -------------------------------------------------------- | ----------------------------------------------- |
257
+ | `--help`, `-h` | Show help text |
258
+ | `--version`, `-v` | Show version number |
259
+ | `--config` | Show port, URL, app version, and SQLite version |
260
+ | `--open` | Open SQLite Hub in the browser |
261
+ | `--port:PORT` | Start the server on a custom port |
262
+ | `--database`, `-d` | List all imported databases |
263
+ | `--database:name` | Select a database by name or id |
264
+ | `--database:name --path` | Get the file path of a database |
265
+ | `--database:name --size` | Get the size of a database |
266
+ | `--database:name --lastopened` | Get the last opened timestamp |
267
+ | `--database:name --tables` | Get all table names from a database |
268
+ | `--database:name --queries` | List saved queries for a database |
269
+ | `--database:name --execute:"query"` | Execute a saved query by name |
270
+ | `--database:name --query:"query"` | Print a saved query by name |
271
+ | `--database:name --notes:"query"` | Print saved notes for a query |
272
+ | `--database:name --export:"query" --format:csv\|tsv\|md` | Set query export format |
273
+ | `--database:name --documents` | List Markdown documents for a database |
274
+ | `--database:name --documents:"document"` | Print a document's Markdown content |
275
+ | `--database:name --documents:"document" --export` | Export a document as Markdown |
276
+ | `--database:name --table:"table"` | Print table metadata |
277
+ | `--database:name --table:"table" --export:"pk"` | Export one row as JSON |
278
+
279
+ Legacy aliases such as `--database-path:name`, `--database-size:name`, `--database-lastopened:name`, `--database-tables:name`, and `--database:name --sqleditor:"query"` still work.
185
280
 
186
281
  ### SQL editor CLI example
187
282
 
@@ -190,7 +285,7 @@ This searches the query history for the given database, finds the matching saved
190
285
  In the screenshot above, you can see a saved query from the SQL editor. You can create these queries using the graphical interface and execute them via the CLI if you want. To execute one, you would run:
191
286
 
192
287
  ```bash
193
- sqlite-hub --database:Unit-00 --sqleditor:"Group by creation Year"
288
+ sqlite-hub --database:Unit-00 --execute:"Group by creation Year"
194
289
  ```
195
290
 
196
291
  Example output: