sqlite-hub 1.2.0 → 1.5.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 (169) hide show
  1. package/README.md +113 -71
  2. package/bin/sqlite-hub.js +723 -116
  3. package/docs/API.md +152 -0
  4. package/docs/CLI.md +249 -0
  5. package/docs/CLI_API_PARITY.md +61 -0
  6. package/docs/changelog.md +149 -0
  7. package/docs/guidelines/AGENTS.md +32 -0
  8. package/docs/guidelines/DESIGN.md +55 -0
  9. package/docs/shortkeys.md +27 -0
  10. package/docs/todo.md +4 -0
  11. package/examples/api/generate-types.js +52 -0
  12. package/frontend/assets/mockups/backups_1_1920.webp +0 -0
  13. package/frontend/assets/mockups/backups_2_create_backup_modal_1920.webp +0 -0
  14. package/frontend/assets/mockups/backups_3_edit_backup_modal_1920.webp +0 -0
  15. package/frontend/assets/mockups/backups_4_restore_backup_modal_1920.webp +0 -0
  16. package/frontend/assets/mockups/backups_5_delete_backup_modal_1920.webp +0 -0
  17. package/frontend/assets/mockups/charts_1_1920.webp +0 -0
  18. package/frontend/assets/mockups/charts_2_query_detail_1920.webp +0 -0
  19. package/frontend/assets/mockups/charts_3_create_query_chart_modal_1920.webp +0 -0
  20. package/frontend/assets/mockups/charts_4_edit_query_chart_modal_1920.webp +0 -0
  21. package/frontend/assets/mockups/charts_5_delete_query_chart_modal_1920.webp +0 -0
  22. package/frontend/assets/mockups/charts_6_copy_column_modal_1920.webp +0 -0
  23. package/frontend/assets/mockups/connections_1_1920.webp +0 -0
  24. package/frontend/assets/mockups/connections_2_create_connection_modal_1920.webp +0 -0
  25. package/frontend/assets/mockups/connections_3_open_connection_modal_1920.webp +0 -0
  26. package/frontend/assets/mockups/data_1_1920.webp +0 -0
  27. package/frontend/assets/mockups/data_2_roweditor_1920.webp +0 -0
  28. package/frontend/assets/mockups/data_3_data_export_modal_1920.webp +0 -0
  29. package/frontend/assets/mockups/documents_1_1920.webp +0 -0
  30. package/frontend/assets/mockups/documents_2_document_insert_table_modal_1920.webp +0 -0
  31. package/frontend/assets/mockups/documents_3_document_insert_note_modal_1920.webp +0 -0
  32. package/frontend/assets/mockups/media_tagging_queue_1_1920.webp +0 -0
  33. package/frontend/assets/mockups/media_tagging_setup_1_1920.webp +0 -0
  34. package/frontend/assets/mockups/media_tagging_setup_2_create_media_tagging_tag_table_modal_1920.webp +0 -0
  35. package/frontend/assets/mockups/media_tagging_setup_3_create_media_tagging_mapping_table_modal_1920.webp +0 -0
  36. package/frontend/assets/mockups/overview_1_1920.webp +0 -0
  37. package/frontend/assets/mockups/settings_1_1920.webp +0 -0
  38. package/frontend/assets/mockups/sql_editor_1_1920.webp +0 -0
  39. package/frontend/assets/mockups/sql_editor_2_query_detail_1920.webp +0 -0
  40. package/frontend/assets/mockups/sql_editor_3_query_export_modal_1920.webp +0 -0
  41. package/frontend/assets/mockups/structure_1_1920.webp +0 -0
  42. package/frontend/assets/mockups/structure_2_generate_types_modal_1920.webp +0 -0
  43. package/frontend/assets/mockups/structure_3_generate_types_modal_1920.webp +0 -0
  44. package/frontend/assets/mockups/table_designer_1_1920.webp +0 -0
  45. package/frontend/assets/mockups/table_designer_2_table_designer_constraints_modal_1920.webp +0 -0
  46. package/frontend/js/api.js +63 -0
  47. package/frontend/js/app.js +310 -10
  48. package/frontend/js/components/connectionCard.js +4 -2
  49. package/frontend/js/components/emptyState.js +4 -4
  50. package/frontend/js/components/generateTypesDropdown.js +33 -0
  51. package/frontend/js/components/metricCard.js +1 -1
  52. package/frontend/js/components/modal.js +555 -21
  53. package/frontend/js/components/pageHeader.js +1 -1
  54. package/frontend/js/components/queryHistoryDetail.js +3 -3
  55. package/frontend/js/components/queryHistoryHeader.js +1 -1
  56. package/frontend/js/components/queryHistoryPanel.js +1 -1
  57. package/frontend/js/components/rowEditorPanel.js +13 -3
  58. package/frontend/js/components/sidebar.js +41 -7
  59. package/frontend/js/components/topNav.js +2 -14
  60. package/frontend/js/router.js +38 -6
  61. package/frontend/js/store.js +870 -8
  62. package/frontend/js/utils/inputClear.js +36 -0
  63. package/frontend/js/utils/syntheticData.js +240 -0
  64. package/frontend/js/views/backups.js +581 -37
  65. package/frontend/js/views/charts.js +9 -9
  66. package/frontend/js/views/connections.js +2 -2
  67. package/frontend/js/views/data.js +17 -1
  68. package/frontend/js/views/documents.js +3 -3
  69. package/frontend/js/views/editor.js +6 -6
  70. package/frontend/js/views/logs.js +339 -0
  71. package/frontend/js/views/mediaTagging.js +7 -5
  72. package/frontend/js/views/overview.js +3 -3
  73. package/frontend/js/views/settings.js +80 -30
  74. package/frontend/js/views/structure.js +12 -1
  75. package/frontend/js/views/tableAdvisor.js +385 -0
  76. package/frontend/js/views/tableDesigner.js +6 -0
  77. package/frontend/styles/base.css +1 -40
  78. package/frontend/styles/components.css +258 -232
  79. package/frontend/styles/structure-graph.css +32 -68
  80. package/frontend/styles/tailwind.css +8 -4
  81. package/frontend/styles/tailwind.generated.css +1 -1
  82. package/frontend/styles/tokens.css +28 -21
  83. package/frontend/styles/views.css +102 -261
  84. package/package.json +18 -2
  85. package/server/routes/backups.js +18 -2
  86. package/server/routes/data.js +45 -0
  87. package/server/routes/externalApi.js +321 -2
  88. package/server/routes/logs.js +127 -0
  89. package/server/routes/structure.js +22 -0
  90. package/server/server.js +3 -0
  91. package/server/services/databaseCommandService.js +59 -0
  92. package/server/services/sqlite/backupDiff.js +914 -0
  93. package/server/services/sqlite/backupService.js +77 -1
  94. package/server/services/sqlite/dataBrowserService.js +36 -0
  95. package/server/services/sqlite/introspection.js +226 -22
  96. package/server/services/sqlite/structureService.js +7 -0
  97. package/server/services/sqlite/syntheticDataGenerator.js +728 -0
  98. package/server/services/sqlite/tableAdvisor.js +790 -0
  99. package/server/services/storage/appStateStore.js +773 -169
  100. package/server/services/typeGenerationService.js +663 -0
  101. package/tailwind.config.cjs +0 -1
  102. package/.github/funding.yml +0 -2
  103. package/.github/workflows/ci.yml +0 -36
  104. package/database.sqlite +0 -0
  105. package/frontend/assets/mockups/charts_1_bars_1200.webp +0 -0
  106. package/frontend/assets/mockups/charts_2_pie_1200.webp +0 -0
  107. package/frontend/assets/mockups/charts_3_scatter_plot_1200.webp +0 -0
  108. package/frontend/assets/mockups/connections_1200.webp +0 -0
  109. package/frontend/assets/mockups/data_1_1200.webp +0 -0
  110. package/frontend/assets/mockups/data_2_row_editor_1200.webp +0 -0
  111. package/frontend/assets/mockups/documents_1200.webp +0 -0
  112. package/frontend/assets/mockups/media_tagging_1_setup_1200.webp +0 -0
  113. package/frontend/assets/mockups/media_tagging_2_tagging_queue_1200.webp +0 -0
  114. package/frontend/assets/mockups/media_tagging_3_media_viewer_1200.webp +0 -0
  115. package/frontend/assets/mockups/overview_1200.webp +0 -0
  116. package/frontend/assets/mockups/settings_1200.webp +0 -0
  117. package/frontend/assets/mockups/sql_editor_1_1200.webp +0 -0
  118. package/frontend/assets/mockups/sql_editor_2_query_details_1200.webp +0 -0
  119. package/frontend/assets/mockups/sql_editor_3_export_column_1200.webp +0 -0
  120. package/frontend/assets/mockups/sql_editor_4_export_column_as_markdown_1200.webp +0 -0
  121. package/frontend/assets/mockups/sql_editor_5_export_query_result_1200.webp +0 -0
  122. package/frontend/assets/mockups/structure_1_1200.webp +0 -0
  123. package/frontend/assets/mockups/structure_2_inspector_1200.webp +0 -0
  124. package/frontend/assets/mockups/table_designer_1_1200.webp +0 -0
  125. package/frontend/assets/mockups/table_designer_2_checks_1200.webp +0 -0
  126. package/tests/api-token-auth.test.js +0 -279
  127. package/tests/backup-manager.test.js +0 -140
  128. package/tests/backups-view.test.js +0 -70
  129. package/tests/charts-height-preset-storage.test.js +0 -60
  130. package/tests/charts-route-state.test.js +0 -144
  131. package/tests/check-constraint-options.test.js +0 -90
  132. package/tests/cli-args.test.js +0 -113
  133. package/tests/cli-service-delegation.test.js +0 -140
  134. package/tests/connection-removal.test.js +0 -52
  135. package/tests/connections-file-dialog-route.test.js +0 -89
  136. package/tests/copy-column-modal.test.js +0 -131
  137. package/tests/database-command-service.test.js +0 -174
  138. package/tests/database-documents.test.js +0 -85
  139. package/tests/documents-view.test.js +0 -132
  140. package/tests/dropdown-button.test.js +0 -101
  141. package/tests/email-preview.test.js +0 -89
  142. package/tests/export-blob.test.js +0 -99
  143. package/tests/export-filenames.test.js +0 -38
  144. package/tests/file-path-preview.test.js +0 -165
  145. package/tests/form-controls.test.js +0 -34
  146. package/tests/json-preview.test.js +0 -49
  147. package/tests/local-request-security.test.js +0 -85
  148. package/tests/markdown-documents.test.js +0 -103
  149. package/tests/native-file-dialog.test.js +0 -105
  150. package/tests/query-editor.test.js +0 -28
  151. package/tests/query-history-detail.test.js +0 -37
  152. package/tests/query-history-header.test.js +0 -30
  153. package/tests/query-results-truncation.test.js +0 -20
  154. package/tests/risky-sql.test.js +0 -30
  155. package/tests/row-editor-json.test.js +0 -82
  156. package/tests/row-editor-null-values.test.js +0 -184
  157. package/tests/row-editor-timestamp-preview.test.js +0 -192
  158. package/tests/security-paths.test.js +0 -84
  159. package/tests/settings-api-tokens-route.test.js +0 -97
  160. package/tests/settings-metadata.test.js +0 -114
  161. package/tests/settings-view.test.js +0 -108
  162. package/tests/sql-formatter.test.js +0 -173
  163. package/tests/sql-highlight.test.js +0 -38
  164. package/tests/sql-identifier-safety.test.js +0 -171
  165. package/tests/sql-result-limit.test.js +0 -66
  166. package/tests/structure-view.test.js +0 -60
  167. package/tests/table-designer-v2-unique-constraints.test.js +0 -78
  168. package/tests/table-scroll-state.test.js +0 -70
  169. package/tests/text-cell-stats.test.js +0 -38
package/docs/API.md ADDED
@@ -0,0 +1,152 @@
1
+ # SQLite Hub API
2
+
3
+ SQLite Hub exposes a versioned JSON API at `/api/v1`. The server listens on
4
+ `127.0.0.1`. `GET /api/v1/info` is public local app metadata; every database
5
+ request requires a token created for that exact database in **Settings > API
6
+ Tokens**.
7
+
8
+ The token is shown only once when it is created. SQLite Hub stores a SHA-256
9
+ hash, the token prefix, its name, and timestamps. Send the token as a bearer
10
+ token:
11
+
12
+ The `DATABASE_ID` is shown prominently in **Settings > API Tokens** for the
13
+ active database. Use the **Copy ID** button there and replace `DATABASE_ID` in
14
+ the request URL.
15
+
16
+ ```bash
17
+ curl \
18
+ -H "Authorization: Bearer shub_..." \
19
+ http://127.0.0.1:4173/api/v1/databases/DATABASE_ID/tables
20
+ ```
21
+
22
+ A missing, invalid, deleted, or database-mismatched token returns HTTP `401`
23
+ with a structured JSON error.
24
+
25
+ ## Endpoints
26
+
27
+ All path values must be URL encoded.
28
+
29
+ ```text
30
+ GET /api/v1/info
31
+ POST /api/v1/query
32
+
33
+ GET /api/v1/databases/:databaseId
34
+ GET /api/v1/databases/:databaseId/tables
35
+ GET /api/v1/databases/:databaseId/tables/:tableName
36
+ POST /api/v1/databases/:databaseId/tables/:tableName/row
37
+ POST /api/v1/databases/:databaseId/tables/:tableName/types
38
+
39
+ GET /api/v1/databases/:databaseId/backups
40
+ POST /api/v1/databases/:databaseId/backups
41
+
42
+ GET /api/v1/databases/:databaseId/queries
43
+ GET /api/v1/databases/:databaseId/queries/:queryName
44
+ GET /api/v1/databases/:databaseId/queries/:queryName/notes
45
+ GET /api/v1/databases/:databaseId/queries/:queryName/export?format=csv|tsv|md|json
46
+ POST /api/v1/databases/:databaseId/queries/:queryName/execute
47
+
48
+ GET /api/v1/databases/:databaseId/documents
49
+ GET /api/v1/databases/:databaseId/documents/:documentName
50
+ GET /api/v1/databases/:databaseId/documents/:documentName/export
51
+ ```
52
+
53
+ `GET /api/v1/info` returns the same app/version status shown by
54
+ `sqlite-hub --info`, including the installed SQLite Hub version, SQLite runtime
55
+ version, local URL, and npm update status.
56
+
57
+ `POST /api/v1/query` executes raw SQL through the same SQL Editor execution path
58
+ used by the app and records it in Query History. Send the database token as a
59
+ bearer token and include `databaseId` plus `sql` in the JSON body. Add `store`
60
+ or `name` to title the history item and mark it as saved. Raw query execution is
61
+ rejected with HTTP `403` when the target database is marked read-only.
62
+
63
+ Every `/api/v1` request is also recorded in the local Access Log with its API
64
+ action, database id when available, target type/name, status, duration, and API
65
+ token name/id. Tokens and request payloads are not stored in the Access Log.
66
+
67
+ ```bash
68
+ curl \
69
+ -H "Authorization: Bearer shub_..." \
70
+ -H "Content-Type: application/json" \
71
+ -d '{"databaseId":"DATABASE_ID","sql":"SELECT * FROM companies LIMIT 10","name":"Company Sample"}' \
72
+ http://127.0.0.1:4173/api/v1/query
73
+ ```
74
+
75
+ Row lookup accepts a scalar key or a composite primary-key object:
76
+
77
+ ```json
78
+ { "key": 42 }
79
+ ```
80
+
81
+ ```json
82
+ { "key": { "id": 42, "locale": "en" } }
83
+ ```
84
+
85
+ `POST /api/v1/databases/:databaseId/tables/:tableName/types` generates
86
+ application types from the declared SQLite schema. It is read-only, uses the
87
+ same generation service as the Structure Inspector and CLI, and returns code as
88
+ JSON without writing server-side files.
89
+
90
+ ```bash
91
+ curl \
92
+ -X POST \
93
+ -H "Authorization: Bearer shub_..." \
94
+ -H "Content-Type: application/json" \
95
+ -d '{
96
+ "target": "typescript",
97
+ "options": {
98
+ "propertyNaming": "camel",
99
+ "nullableMode": "native",
100
+ "includeComments": true
101
+ }
102
+ }' \
103
+ http://127.0.0.1:4173/api/v1/databases/DATABASE_ID/tables/users/types
104
+ ```
105
+
106
+ Supported targets are `typescript`, `rust`, `kotlin`, and `swift`. Warnings are
107
+ returned in the top-level `warnings` array. Metadata includes column counts and
108
+ CHECK-constraint counts.
109
+
110
+ `GET /api/v1/databases/:databaseId/backups` lists managed backups for the
111
+ token's database.
112
+
113
+ ```bash
114
+ curl \
115
+ -H "Authorization: Bearer shub_..." \
116
+ http://127.0.0.1:4173/api/v1/databases/DATABASE_ID/backups
117
+ ```
118
+
119
+ `POST /api/v1/databases/:databaseId/backups` creates and verifies a managed
120
+ backup for the token's database. The request body may include `name` and `notes`.
121
+ Backup creation uses SQLite's backup API and is allowed for read-only database
122
+ connections because the source database is only read.
123
+
124
+ ```bash
125
+ curl \
126
+ -X POST \
127
+ -H "Authorization: Bearer shub_..." \
128
+ -H "Content-Type: application/json" \
129
+ -d '{"name":"Before import","notes":"Before loading vendor data"}' \
130
+ http://127.0.0.1:4173/api/v1/databases/DATABASE_ID/backups
131
+ ```
132
+
133
+ Successful responses use this envelope:
134
+
135
+ ```json
136
+ {
137
+ "success": true,
138
+ "message": "",
139
+ "data": {},
140
+ "metadata": {},
141
+ "warnings": []
142
+ }
143
+ ```
144
+
145
+ Errors use the same envelope with `success: false` and a structured `error`
146
+ object containing `code`, `message`, `details`, and `sqliteCode`.
147
+
148
+ ## Example
149
+
150
+ See [`examples/api/list-tables.js`](../examples/api/list-tables.js) for a small
151
+ Node.js example using a token from the `SQLITE_HUB_API_TOKEN` environment
152
+ variable.
package/docs/CLI.md ADDED
@@ -0,0 +1,249 @@
1
+ # SQLite Hub CLI
2
+
3
+ SQLite Hub ships with a built-in CLI that lets you start the app, inspect
4
+ imported databases, execute raw or saved SQL, export query results, and work
5
+ with Markdown documents from the terminal.
6
+
7
+ CLI commands are recorded in the local Access Log with their action, target,
8
+ database id when available, status, and duration. Raw SQL text is still handled
9
+ by Query History for executed queries and is not duplicated in the Access Log.
10
+
11
+ ## Start The App
12
+
13
+ ```bash
14
+ sqlite-hub # start on default port 4173
15
+ sqlite-hub --port:4174 # start on a custom port
16
+ sqlite-hub --open # open SQLite Hub in the browser
17
+ sqlite-hub --info # show port, URL, versions, and update status
18
+ sqlite-hub --help # show help text
19
+ sqlite-hub --version # show version number
20
+ ```
21
+
22
+ `--config` is still accepted as a legacy alias for `--info`.
23
+
24
+ ## Databases
25
+
26
+ List all imported databases:
27
+
28
+ ```bash
29
+ sqlite-hub --database
30
+ sqlite-hub -d
31
+ ```
32
+
33
+ The database list shows the name, file path, file size, last opened timestamp,
34
+ and read-only status for databases that have been opened in SQLite Hub.
35
+
36
+ Query details for one database by name or id:
37
+
38
+ ```bash
39
+ sqlite-hub --database:Billly --path # get the file path
40
+ sqlite-hub --database:Billly --size # get the file size
41
+ sqlite-hub --database:Billly --lastopened # get last opened timestamp
42
+ ```
43
+
44
+ List all tables in a database:
45
+
46
+ ```bash
47
+ sqlite-hub --database:Billly --tables
48
+ ```
49
+
50
+ Inspect one table:
51
+
52
+ ```bash
53
+ sqlite-hub --database:Billly --table:companies
54
+ ```
55
+
56
+ Table inspection prints metadata such as columns, primary keys, foreign keys,
57
+ indexes, row count, and row identity strategy.
58
+
59
+ Generate application types from a table schema:
60
+
61
+ ```bash
62
+ sqlite-hub --database:Unit-00 --table:users --types:typescript
63
+ sqlite-hub --database:Unit-00 --table:users --types:rust
64
+ sqlite-hub --database:Unit-00 --table:users --types:typescript --json
65
+ sqlite-hub --database:Unit-00 --table:users --types:typescript --output:User.ts
66
+ ```
67
+
68
+ Aliases are available for common targets: `ts`, `rs`, and `kt`. Without
69
+ `--output` or `--json`, the CLI writes only generated code to stdout so shell
70
+ redirection works cleanly. Warnings are written to stderr. Use `--force` to
71
+ overwrite an existing output file.
72
+
73
+ Create a verified managed backup for a database:
74
+
75
+ ```bash
76
+ sqlite-hub --database:Unit-00 --backups
77
+ sqlite-hub --database:Unit-00 --backup
78
+ sqlite-hub --database:Unit-00 --backup:"Before import" --backup-notes:"Before loading vendor data"
79
+ sqlite-hub --database:Unit-00 --backup:"Nightly checkpoint" --json
80
+ ```
81
+
82
+ Backup creation uses the same SQLite backup API and verification path as the UI
83
+ Backup Manager. It works for read-only database connections because the source
84
+ database is only read. `--backups` lists the managed backups for the selected
85
+ database; add `--json` for structured output.
86
+
87
+ ## SQL Editor
88
+
89
+ Execute raw SQL through the same SQL Editor execution path used by the app:
90
+
91
+ ```bash
92
+ sqlite-hub --database:Unit-00 --query:"SELECT * FROM companies LIMIT 10"
93
+ sqlite-hub --database:Unit-00 --query:"SELECT * FROM companies LIMIT 10" --store:"Company Sample"
94
+ ```
95
+
96
+ Raw CLI queries are recorded in Query History. Add `--store:"name"` to title the
97
+ history item and mark it as saved. Raw SQL execution is rejected when the target
98
+ database is marked read-only.
99
+
100
+ List all saved queries for a database:
101
+
102
+ ```bash
103
+ sqlite-hub --database:Unit-00 --queries
104
+ ```
105
+
106
+ Execute a specific saved query by name:
107
+
108
+ ```bash
109
+ sqlite-hub --database:Unit-00 --execute:"15min Posting Buckets without id 96"
110
+ ```
111
+
112
+ This searches the query history for the selected database, finds the matching
113
+ saved query by title, executes it, and returns results with metadata such as row
114
+ count, columns, timing, and data.
115
+
116
+ Show the saved query SQL without executing it:
117
+
118
+ ```bash
119
+ sqlite-hub --database:Unit-00 --saved-query:"Stock Winners"
120
+ ```
121
+
122
+ Show the saved notes for a query:
123
+
124
+ ```bash
125
+ sqlite-hub --database:Unit-00 --notes:"TOP25 Loser and Winner EOD, T1, T3, T5"
126
+ ```
127
+
128
+ Export a saved query using the same CSV, TSV, Markdown, and JSON export logic as
129
+ the SQL Editor:
130
+
131
+ ```bash
132
+ sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:csv
133
+ sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:tsv
134
+ sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:md
135
+ sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:json
136
+ ```
137
+
138
+ The export is written to the current working directory using the generated query
139
+ export filename.
140
+
141
+ ## Documents
142
+
143
+ List all Markdown documents stored for a database:
144
+
145
+ ```bash
146
+ sqlite-hub --database:Unit-00 --documents
147
+ ```
148
+
149
+ Print one document's Markdown content:
150
+
151
+ ```bash
152
+ sqlite-hub --database:Unit-00 --documents:"Research Notes"
153
+ ```
154
+
155
+ Export one document as a `.md` file into the current working directory:
156
+
157
+ ```bash
158
+ sqlite-hub --database:Unit-00 --documents:"Research Notes" --export
159
+ sqlite-hub --database:Unit-00 --documents:"Research Notes--export"
160
+ ```
161
+
162
+ Documents can be matched by id, filename, title, or a partial filename/title
163
+ match.
164
+
165
+ ## Row JSON Export
166
+
167
+ Export a single row as JSON by primary key or rowid, using the same row-shaping
168
+ logic as the Row Editor:
169
+
170
+ ```bash
171
+ sqlite-hub --database:Unit-00 --table:companies --export:0a754aba373d34972998792a0be4333c
172
+ ```
173
+
174
+ ## Available Flags
175
+
176
+ | Flag | Description |
177
+ | --------------------------------------------------------------- | ----------------------------------------------- |
178
+ | `--help`, `-h` | Show help text |
179
+ | `--version`, `-v` | Show version number |
180
+ | `--info` | Show port, URL, versions, and update status |
181
+ | `--open` | Open SQLite Hub in the browser |
182
+ | `--port:PORT` | Start the server on a custom port |
183
+ | `--database`, `-d` | List all imported databases |
184
+ | `--database:name` | Select a database by name or id |
185
+ | `--database:name --path` | Get the file path of a database |
186
+ | `--database:name --size` | Get the size of a database |
187
+ | `--database:name --lastopened` | Get the last opened timestamp |
188
+ | `--database:name --tables` | Get all table names from a database |
189
+ | `--database:name --queries` | List saved queries for a database |
190
+ | `--database:name --query:"sql"` | Execute raw SQL and record it in Query History |
191
+ | `--database:name --query:"sql" --store:"name"` | Save a raw query in Query History with a name |
192
+ | `--database:name --execute:"query"` | Execute a saved query by name |
193
+ | `--database:name --saved-query:"query"` | Print a saved query by name |
194
+ | `--database:name --notes:"query"` | Print saved notes for a query |
195
+ | `--database:name --export:"query" --format:csv\|tsv\|md\|json` | Set query export format |
196
+ | `--database:name --documents` | List Markdown documents for a database |
197
+ | `--database:name --documents:"document"` | Print a document's Markdown content |
198
+ | `--database:name --documents:"document" --export` | Export a document as Markdown |
199
+ | `--database:name --backups` | List managed backups for a database |
200
+ | `--database:name --backup` | Create and verify a managed backup |
201
+ | `--database:name --backup:"name"` | Create a managed backup with a custom name |
202
+ | `--backup-notes:"text"` | Add notes to a backup created by `--backup` |
203
+ | `--database:name --table:"table"` | Print table metadata |
204
+ | `--database:name --table:"table" --export:"pk"` | Export one row as JSON |
205
+ | `--database:name --table:"table" --types:typescript\|ts\|rust\|rs\|kotlin\|kt\|swift` | Generate application types |
206
+ | `--type-name:"name"` | Override generated type name |
207
+ | `--naming:preserve\|camel\|pascal\|snake` | Select property naming |
208
+ | `--nullable:native\|optional` | Select nullable handling |
209
+ | `--comments` | Include schema comments |
210
+ | `--defaults-as-comments` | Include default values as comments |
211
+ | `--json-type:unknown\|record\|json-value` | Select TypeScript JSON mapping |
212
+ | `--include-generated` | Include generated columns |
213
+ | `--include-hidden` | Include hidden columns |
214
+ | `--output:"file"` | Write generated types to a file |
215
+ | `--json` | Print generated type result as JSON |
216
+ | `--force` | Overwrite existing `--output` file |
217
+
218
+ Legacy aliases such as `--config`, `--database-path:name`,
219
+ `--database-size:name`, `--database-lastopened:name`, `--database-tables:name`,
220
+ and `--database:name --sqleditor:"query"` still work.
221
+
222
+ ## Example
223
+
224
+ Saved queries created in the graphical SQL Editor can also be executed through
225
+ the CLI. To execute one, run:
226
+
227
+ ```bash
228
+ sqlite-hub --database:Unit-00 --execute:"Group by creation Year"
229
+ ```
230
+
231
+ Example output:
232
+
233
+ ```bash
234
+ Executing: Group by creation Year
235
+ SQL: SELECT STRFTIME('%Y', creation_time, 'unixepoch') AS creation_year, COUNT(*) AS channel_count FROM channels WHERE creation_time IS NOT NU...
236
+ ------------------------------------------------------------
237
+
238
+ Statement count: 1
239
+ Timing: 1ms
240
+
241
+ Statement 1 (resultSet):
242
+ Rows: 3
243
+ Columns: creation_year, channel_count
244
+
245
+ Results:
246
+ [0] 2024 | 11
247
+ [1] 2025 | 47
248
+ [2] 2026 | 40
249
+ ```
@@ -0,0 +1,61 @@
1
+ # CLI / External API Parity
2
+
3
+ This document compares the public CLI (`sqlite-hub ...`) with the versioned external API (`/api/v1`). It does not treat the internal browser routes under `/api/*` as stable automation surfaces.
4
+
5
+ ## Capability Matrix
6
+
7
+ | Capability | CLI | `/api/v1` | Parity | Notes |
8
+ | --------------------- | ------------------------------------------------------ | ----------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------- |
9
+ | App info | `sqlite-hub --info` | `GET /api/v1/info` | Full | Both return app/runtime/version status. |
10
+ | Start/open app | `sqlite-hub`, `--port`, `--open` | No | CLI only | API assumes the server is already running. |
11
+ | List known databases | `--database` | No | CLI only | API requires a specific database id and token. |
12
+ | Database detail | `--database:name --path/--size/--lastopened` | `GET /databases/:databaseId` | Partial | API returns structured detail for one authorized database. CLI can discover databases by name/id. |
13
+ | List tables | `--database:name --tables` | `GET /databases/:databaseId/tables` | Full | Output format differs: terminal text vs JSON. |
14
+ | Inspect table | `--database:name --table:name` | `GET /databases/:databaseId/tables/:tableName` | Full | Both expose columns, keys, indexes, counts, and identity metadata. |
15
+ | Raw SQL execution | `--query:"SQL"` | `POST /api/v1/query` | Full | Both use SQL Editor execution and write Query History. |
16
+ | Save raw query | `--query:"SQL" --store:"Name"` | `POST /api/v1/query` with `store` or `name` | Full | Both title the history item and mark it saved. |
17
+ | List saved queries | `--queries` | `GET /databases/:databaseId/queries` | Full | Saved query collection only. |
18
+ | Get saved query SQL | `--saved-query:"Name"` | `GET /databases/:databaseId/queries/:queryName` | Full | API returns structured query metadata. |
19
+ | Get saved query notes | `--notes:"Name"` | `GET /databases/:databaseId/queries/:queryName/notes` | Full | Same saved-query lookup behavior. |
20
+ | Execute saved query | `--execute:"Name"` | `POST /databases/:databaseId/queries/:queryName/execute` | Full | Both return result metadata and rows. |
21
+ | Export saved query | `--export:"Name" --format:csv\|tsv\|md\|json` | `GET /databases/:databaseId/queries/:queryName/export?format=...` | Partial | Same formats. CLI writes a file; API returns content in JSON. |
22
+ | List documents | `--documents` | `GET /databases/:databaseId/documents` | Full | Read-only document listing. |
23
+ | Read document | `--documents:"Name"` | `GET /databases/:databaseId/documents/:documentName` | Full | API returns the document object. |
24
+ | Export document | `--documents:"Name" --export` | `GET /databases/:databaseId/documents/:documentName/export` | Partial | CLI writes Markdown to disk; API returns content and filename. |
25
+ | Row JSON export | `--table:name --export:"pk"` | `POST /databases/:databaseId/tables/:tableName/row` | Full | API body supports scalar or composite key objects. |
26
+ | Generate schema types | `--table:name --types:typescript\|rust\|kotlin\|swift` | `POST /databases/:databaseId/tables/:tableName/types` | Partial | Same generator. CLI supports stdout/file output and aliases; API returns JSON. |
27
+ | List backups | `--backups` | `GET /databases/:databaseId/backups` | Full | Both return managed backups for one database. |
28
+ | Create backup | `--backup`, `--backup:"name"` | `POST /databases/:databaseId/backups` | Full | Both create and verify a managed backup through the same service. |
29
+
30
+ ## Stable Surface Gaps
31
+
32
+ These UI features currently have no public CLI or `/api/v1` equivalent:
33
+
34
+ - Backups: verify, compare, restore, download, edit notes, delete, usage summary.
35
+ - Table Advisor: run deterministic table analysis and copy SQL recommendations.
36
+ - Synthetic Data: preview and insert generated rows.
37
+ - Table Designer: create/edit tables, CSV-seed drafts, apply SQL preview.
38
+ - Charts: create, edit, delete, resize, and export PNG.
39
+ - Logs: filtered access/query history inspection.
40
+ - Settings/API tokens: create, delete, inspect token usage.
41
+ - Connections: open/create databases, edit labels/paths/icons/read-only mode, remove registry entries.
42
+ - Documents mutation: create, edit, autosave, import, delete, insert saved-query tables/notes.
43
+ - Row editing and table data mutation through the Data Browser.
44
+ - Media Tagging setup and queue actions.
45
+ - Overview Finder action.
46
+
47
+ ## Recommended Parity Order
48
+
49
+ 1. **Table Advisor**: read-only, deterministic, low risk, useful for automation.
50
+ 2. **Backups**: list and create are exposed; verify, restore, and download should follow.
51
+ 3. **Logs**: read-only observability with filters.
52
+ 4. **Synthetic Data**: useful for test automation; needs clear write safeguards.
53
+ 5. **Table Designer**: powerful but schema-mutating, so it needs dry-run/preview-first API design.
54
+ 6. **Charts**: lower priority for CLI, useful as API metadata/export later.
55
+
56
+ ## Design Notes
57
+
58
+ - Keep `/api/v1` token-scoped by database.
59
+ - Keep write operations explicit and reject read-only databases consistently.
60
+ - Prefer JSON responses for API and file/stdout behavior for CLI.
61
+ - Reuse existing services where possible so UI, CLI, and API stay behaviorally aligned.
@@ -0,0 +1,149 @@
1
+ # v1.5.0
2
+
3
+ - synthetic data generation
4
+ - logs for everything in the log menu
5
+ - in api tokens you can now see last used and amount of api calls
6
+ - removed legacy tables
7
+ - new menu/view order
8
+
9
+ # v1.4.0
10
+
11
+ - Schema Diff / Database Diff in backups
12
+
13
+ # v1.3.0
14
+
15
+ - remove unused css and duplicates, css code rework
16
+ - UX Audit from @corneliakocher
17
+ - edit name and notes for backup
18
+ - generate types from schema to typescript, kotlin, rust, swift
19
+ - open row editor drawer with id hash http://127.0.0.1:4180/#/data#14a06a1ffa23e08ae86becec0c5d8b38
20
+
21
+ # v1.1.2
22
+
23
+ - documents overhaul
24
+ - introducing the SQLite Hub dropdown button
25
+ - backup manager
26
+
27
+ # v1.1.1
28
+
29
+ - table designer overhaul
30
+
31
+ # v1.1.0
32
+
33
+ - making the UI more consistent
34
+ - structure overhaul, better UI
35
+ - chart overhaul, better UI, search, etz
36
+ - store last position of structure
37
+ - join preview in structure
38
+ - export JSON for Data, SQL Editor
39
+ - export parquet for Data, SQL Editor
40
+ - check updates for new versions in settings
41
+ - Global Database Search
42
+
43
+ # v1.0.0
44
+
45
+ - Removed external Tailwind.
46
+ - Fixed vibe-coding issues with https://github.com/oliverjessner/ItWorksBut.
47
+ - Persisted saved/recent chart tabs in localStorage.
48
+ - Updated dependencies.
49
+ - Replaced innerHTML with DOM functions.
50
+ - Display execution time in seconds when it exceeds 10 seconds.
51
+ - The Performance panel in the SQL Editor shows query memory size.
52
+ - The Structure view remembers the last selected table.
53
+ - Removed pixel shift bug in SQL Editor on the bottom cards
54
+ - title name changing depending on the menu
55
+ - in messages you can see your executed query
56
+ - secure execute for destructive queries
57
+ - 250 page size, advanced search in data
58
+ - export TSV, CSV, markdown, duplicate as table
59
+ - copy from and export column function, with separator and wrapper
60
+ - quick picks for database
61
+ - export row as json
62
+ - row editor shows urls and opens in browser, path detection, timestamp detection
63
+ - format button in SQLEditor
64
+ - API
65
+
66
+ # v0.9.3
67
+
68
+ - Improved re-rendering.
69
+ - Fixed the sorting bug in Charts.
70
+ - Stored the data row size in localStorage.
71
+ - Saved charts.
72
+
73
+ # v0.9.1
74
+
75
+ - Tagging queue improvements.
76
+ - Rotate right and rotate left.
77
+
78
+ # v0.9.0
79
+
80
+ - Tagging view.
81
+ - Filtered Create, Update, and Delete queries out of the chart section.
82
+
83
+ # v0.8.8
84
+
85
+ - Fixed the delete-query modal window.
86
+ - CSV export filenames are based on query names.
87
+ - Unsaved query history tab.
88
+
89
+ # v0.8.7
90
+
91
+ - UX fixes.
92
+ - Fixed a lot of vibe slop.
93
+ - Started building reusable components.
94
+
95
+ # v0.8.0
96
+
97
+ - DDL copy button.
98
+ - Open in Charts button in query details.
99
+ - Clear makes the editor active.
100
+ - UI fixes.
101
+ - Overview improvements.
102
+
103
+ # v0.7.0
104
+
105
+ - Hide Query History and Hide Editor controls.
106
+ - Better CLI interface.
107
+ - Plotting and graphs.
108
+ - Removed UI inconsistencies.
109
+
110
+ # v0.6.0
111
+
112
+ - Table Designer: create tables in SQLite Hub.
113
+
114
+ # v0.5.1
115
+
116
+ - Bug fix in the SQL Editor.
117
+
118
+ # v0.5.0
119
+
120
+ - SQL query history.
121
+ - Open in Finder from Overview.
122
+ - Sort columns in Data and the SQL Editor.
123
+ - JSON view in the row editor.
124
+
125
+ # v0.4.0
126
+
127
+ - Search in Data.
128
+ - Shift + Enter.
129
+ - Database logos.
130
+ - Cleaned up some chaotic code.
131
+
132
+ # v0.3.2
133
+
134
+ - Delete rows.
135
+ - Modal windows for rows.
136
+
137
+ # v0.3.1
138
+
139
+ - Visualize tables.
140
+ - Export CSV from Data and the SQL Editor.
141
+ - Backup mode.
142
+
143
+ # v0.2.0
144
+
145
+ - Database fix.
146
+
147
+ # v0.1.3
148
+
149
+ - Edit in the SQL Editor.
@@ -0,0 +1,32 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+
5
+ SQLite Hub is a local-first Node/Express app with a browser SPA. Backend code lives in `server/`: routes in `server/routes`, domain services in `server/services`, SQLite helpers in `server/services/sqlite`, and shared utilities in `server/utils`. Frontend code lives in `frontend/`: views in `frontend/js/views`, reusable UI in `frontend/js/components`, state/router logic in `frontend/js/store.js` and `frontend/js/router.js`, and styles in `frontend/styles`. CLI entrypoint code is in `bin/sqlite-hub.js`. Tests are in `tests/*.test.js`. Documentation is in `docs/`, with user-facing overview content in `README.md`.
6
+
7
+ ## Build, Test, and Development Commands
8
+
9
+ - `npm run dev` starts the local server with Node watch mode on port `4180`.
10
+ - `npm start` runs the packaged CLI entrypoint.
11
+ - `npm test` runs all Node test files under `tests/`.
12
+ - `npm run build` or `npm run build:css` regenerates `frontend/styles/tailwind.generated.css`.
13
+ - `npm run screenshots` refreshes the standard screenshot set; use `npm run screenshots:backup-drawer` for the backup drawer capture.
14
+ - `npm run audit` checks production dependencies for high-severity issues.
15
+
16
+ ## Coding Style & Naming Conventions
17
+
18
+ Use plain JavaScript and existing local patterns. Frontend modules use ES modules; backend modules mostly use CommonJS. Prefer small, focused functions and reuse existing components before adding new UI primitives. Keep UI work aligned with `/docs/guidelines/DESIGN.md`; shared button, input, drawer, modal, and Escape-key behavior should stay consistent. Use descriptive camelCase for functions and variables, PascalCase only for classes/services, and route/view files named by feature, for example `tableAdvisor.js`.
19
+
20
+ ## Testing Guidelines
21
+
22
+ Tests use the built-in Node test runner (`node:test`) with `node:assert/strict`. Name files `feature-name.test.js` and keep fixtures local to each test unless reuse is clearly helpful. Add focused tests for backend services, routes, state changes, and rendered view markup when behavior changes. Run the relevant focused test first, then `npm test` before handing off.
23
+ You can use the test database id:conn_c3b310c3373fda5a
24
+ for all tests.
25
+
26
+ ## Commit & Pull Request Guidelines
27
+
28
+ Recent history uses short, informal messages, but contributors should keep commits clear and scoped, for example `add table advisor view` or `fix backup usage summary`. Pull requests should include a concise summary, test commands run, linked issue or context when available, and screenshots for visible UI changes. Note any generated files, especially `frontend/styles/tailwind.generated.css`, when CSS utilities change.
29
+
30
+ ## Security & Configuration Tips
31
+
32
+ Do not commit local databases, tokens, or `.env` files. Use `.env.example` for documented configuration. Local API changes must preserve loopback-only and API-token protections in `server/middleware`.