sqlite-hub 1.1.2 → 1.4.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.
- package/README.md +106 -73
- package/bin/sqlite-hub.js +176 -2
- package/docs/API.md +122 -0
- package/docs/CLI.md +227 -0
- package/docs/DESIGN_GUIDELINES.md +45 -0
- package/docs/changelog.md +141 -0
- package/docs/shortkeys.md +27 -0
- package/docs/todo.md +16 -0
- package/examples/api/generate-types.js +52 -0
- package/frontend/assets/mockups/backups_1_1920.webp +0 -0
- package/frontend/assets/mockups/backups_2_create_backup_modal_1920.webp +0 -0
- package/frontend/assets/mockups/backups_3_edit_backup_modal_1920.webp +0 -0
- package/frontend/assets/mockups/backups_4_restore_backup_modal_1920.webp +0 -0
- package/frontend/assets/mockups/backups_5_delete_backup_modal_1920.webp +0 -0
- package/frontend/assets/mockups/charts_1_1920.webp +0 -0
- package/frontend/assets/mockups/charts_2_query_detail_1920.webp +0 -0
- package/frontend/assets/mockups/charts_3_create_query_chart_modal_1920.webp +0 -0
- package/frontend/assets/mockups/charts_4_edit_query_chart_modal_1920.webp +0 -0
- package/frontend/assets/mockups/charts_5_delete_query_chart_modal_1920.webp +0 -0
- package/frontend/assets/mockups/charts_6_copy_column_modal_1920.webp +0 -0
- package/frontend/assets/mockups/connections_1_1920.webp +0 -0
- package/frontend/assets/mockups/connections_2_create_connection_modal_1920.webp +0 -0
- package/frontend/assets/mockups/connections_3_open_connection_modal_1920.webp +0 -0
- package/frontend/assets/mockups/data_1_1920.webp +0 -0
- package/frontend/assets/mockups/data_2_roweditor_1920.webp +0 -0
- package/frontend/assets/mockups/data_3_data_export_modal_1920.webp +0 -0
- package/frontend/assets/mockups/documents_1_1920.webp +0 -0
- package/frontend/assets/mockups/documents_2_document_insert_table_modal_1920.webp +0 -0
- package/frontend/assets/mockups/documents_3_document_insert_note_modal_1920.webp +0 -0
- package/frontend/assets/mockups/media_tagging_queue_1_1920.webp +0 -0
- package/frontend/assets/mockups/media_tagging_setup_1_1920.webp +0 -0
- package/frontend/assets/mockups/media_tagging_setup_2_create_media_tagging_tag_table_modal_1920.webp +0 -0
- package/frontend/assets/mockups/media_tagging_setup_3_create_media_tagging_mapping_table_modal_1920.webp +0 -0
- package/frontend/assets/mockups/overview_1_1920.webp +0 -0
- package/frontend/assets/mockups/settings_1_1920.webp +0 -0
- package/frontend/assets/mockups/sql_editor_1_1920.webp +0 -0
- package/frontend/assets/mockups/sql_editor_2_query_detail_1920.webp +0 -0
- package/frontend/assets/mockups/sql_editor_3_query_export_modal_1920.webp +0 -0
- package/frontend/assets/mockups/structure_1_1920.webp +0 -0
- package/frontend/assets/mockups/structure_2_generate_types_modal_1920.webp +0 -0
- package/frontend/assets/mockups/structure_3_generate_types_modal_1920.webp +0 -0
- package/frontend/assets/mockups/table_designer_1_1920.webp +0 -0
- package/frontend/assets/mockups/table_designer_2_table_designer_constraints_modal_1920.webp +0 -0
- package/frontend/js/api.js +18 -0
- package/frontend/js/app.js +209 -13
- package/frontend/js/components/connectionCard.js +1 -1
- package/frontend/js/components/emptyState.js +4 -4
- package/frontend/js/components/generateTypesDropdown.js +33 -0
- package/frontend/js/components/metricCard.js +1 -1
- package/frontend/js/components/modal.js +211 -18
- package/frontend/js/components/pageHeader.js +1 -1
- package/frontend/js/components/queryHistoryDetail.js +3 -3
- package/frontend/js/components/queryHistoryHeader.js +1 -1
- package/frontend/js/components/queryHistoryPanel.js +1 -1
- package/frontend/js/components/queryResults.js +1 -1
- package/frontend/js/components/rowEditorPanel.js +65 -16
- package/frontend/js/components/topNav.js +1 -4
- package/frontend/js/components/workspaceOpenDropdown.js +52 -0
- package/frontend/js/router.js +28 -6
- package/frontend/js/store.js +489 -9
- package/frontend/js/utils/emailPreview.js +28 -0
- package/frontend/js/utils/markdownDocuments.js +17 -1
- package/frontend/js/views/backups.js +556 -36
- package/frontend/js/views/charts.js +9 -9
- package/frontend/js/views/connections.js +2 -2
- package/frontend/js/views/data.js +43 -17
- package/frontend/js/views/documents.js +3 -3
- package/frontend/js/views/editor.js +6 -6
- package/frontend/js/views/mediaTagging.js +7 -5
- package/frontend/js/views/overview.js +3 -3
- package/frontend/js/views/settings.js +4 -3
- package/frontend/js/views/structure.js +27 -10
- package/frontend/js/views/tableDesigner.js +23 -0
- package/frontend/styles/base.css +1 -40
- package/frontend/styles/components.css +114 -232
- package/frontend/styles/structure-graph.css +32 -68
- package/frontend/styles/tailwind.css +8 -4
- package/frontend/styles/tailwind.generated.css +1 -1
- package/frontend/styles/tokens.css +29 -21
- package/frontend/styles/views.css +94 -261
- package/package.json +18 -2
- package/server/routes/backups.js +18 -2
- package/server/routes/externalApi.js +36 -0
- package/server/routes/structure.js +22 -0
- package/server/services/databaseCommandService.js +14 -0
- package/server/services/sqlite/backupDiff.js +914 -0
- package/server/services/sqlite/backupService.js +77 -1
- package/server/services/sqlite/structureService.js +7 -0
- package/server/services/typeGenerationService.js +663 -0
- package/tailwind.config.cjs +0 -1
- package/.github/funding.yml +0 -2
- package/.github/workflows/ci.yml +0 -36
- package/database.sqlite +0 -0
- package/frontend/assets/mockups/charts_1_bars_1200.webp +0 -0
- package/frontend/assets/mockups/charts_2_pie_1200.webp +0 -0
- package/frontend/assets/mockups/charts_3_scatter_plot_1200.webp +0 -0
- package/frontend/assets/mockups/connections_1200.webp +0 -0
- package/frontend/assets/mockups/data_1_1200.webp +0 -0
- package/frontend/assets/mockups/data_2_row_editor_1200.webp +0 -0
- package/frontend/assets/mockups/documents_1200.webp +0 -0
- package/frontend/assets/mockups/media_tagging_1_setup_1200.webp +0 -0
- package/frontend/assets/mockups/media_tagging_2_tagging_queue_1200.webp +0 -0
- package/frontend/assets/mockups/media_tagging_3_media_viewer_1200.webp +0 -0
- package/frontend/assets/mockups/overview_1200.webp +0 -0
- package/frontend/assets/mockups/settings_1200.webp +0 -0
- package/frontend/assets/mockups/sql_editor_1_1200.webp +0 -0
- package/frontend/assets/mockups/sql_editor_2_query_details_1200.webp +0 -0
- package/frontend/assets/mockups/sql_editor_3_export_column_1200.webp +0 -0
- package/frontend/assets/mockups/sql_editor_4_export_column_as_markdown_1200.webp +0 -0
- package/frontend/assets/mockups/sql_editor_5_export_query_result_1200.webp +0 -0
- package/frontend/assets/mockups/structure_1_1200.webp +0 -0
- package/frontend/assets/mockups/structure_2_inspector_1200.webp +0 -0
- package/frontend/assets/mockups/table_designer_1_1200.webp +0 -0
- package/frontend/assets/mockups/table_designer_2_checks_1200.webp +0 -0
- package/tests/api-token-auth.test.js +0 -279
- package/tests/backup-manager.test.js +0 -140
- package/tests/backups-view.test.js +0 -64
- package/tests/charts-height-preset-storage.test.js +0 -60
- package/tests/charts-route-state.test.js +0 -144
- package/tests/check-constraint-options.test.js +0 -90
- package/tests/cli-args.test.js +0 -113
- package/tests/cli-service-delegation.test.js +0 -140
- package/tests/connection-removal.test.js +0 -52
- package/tests/connections-file-dialog-route.test.js +0 -89
- package/tests/copy-column-modal.test.js +0 -131
- package/tests/database-command-service.test.js +0 -174
- package/tests/database-documents.test.js +0 -85
- package/tests/documents-view.test.js +0 -132
- package/tests/dropdown-button.test.js +0 -75
- package/tests/export-blob.test.js +0 -99
- package/tests/export-filenames.test.js +0 -38
- package/tests/file-path-preview.test.js +0 -165
- package/tests/form-controls.test.js +0 -34
- package/tests/json-preview.test.js +0 -49
- package/tests/local-request-security.test.js +0 -85
- package/tests/markdown-documents.test.js +0 -79
- package/tests/native-file-dialog.test.js +0 -105
- package/tests/query-editor.test.js +0 -28
- package/tests/query-history-detail.test.js +0 -37
- package/tests/query-history-header.test.js +0 -30
- package/tests/query-results-truncation.test.js +0 -20
- package/tests/risky-sql.test.js +0 -30
- package/tests/row-editor-json.test.js +0 -82
- package/tests/row-editor-null-values.test.js +0 -155
- package/tests/row-editor-timestamp-preview.test.js +0 -192
- package/tests/security-paths.test.js +0 -84
- package/tests/settings-api-tokens-route.test.js +0 -97
- package/tests/settings-metadata.test.js +0 -114
- package/tests/settings-view.test.js +0 -107
- package/tests/sql-formatter.test.js +0 -173
- package/tests/sql-highlight.test.js +0 -38
- package/tests/sql-identifier-safety.test.js +0 -171
- package/tests/sql-result-limit.test.js +0 -66
- package/tests/structure-view.test.js +0 -56
- package/tests/table-designer-v2-unique-constraints.test.js +0 -78
- package/tests/table-scroll-state.test.js +0 -70
- package/tests/text-cell-stats.test.js +0 -38
package/docs/API.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
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/queries
|
|
40
|
+
GET /api/v1/databases/:databaseId/queries/:queryName
|
|
41
|
+
GET /api/v1/databases/:databaseId/queries/:queryName/notes
|
|
42
|
+
GET /api/v1/databases/:databaseId/queries/:queryName/export?format=csv|tsv|md|json
|
|
43
|
+
POST /api/v1/databases/:databaseId/queries/:queryName/execute
|
|
44
|
+
|
|
45
|
+
GET /api/v1/databases/:databaseId/documents
|
|
46
|
+
GET /api/v1/databases/:databaseId/documents/:documentName
|
|
47
|
+
GET /api/v1/databases/:databaseId/documents/:documentName/export
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`GET /api/v1/info` returns the same app/version status shown by
|
|
51
|
+
`sqlite-hub --info`, including the installed SQLite Hub version, SQLite runtime
|
|
52
|
+
version, local URL, and npm update status.
|
|
53
|
+
|
|
54
|
+
`POST /api/v1/query` executes raw SQL through the same SQL Editor execution path
|
|
55
|
+
used by the app and records it in Query History. Send the database token as a
|
|
56
|
+
bearer token and include `databaseId` plus `sql` in the JSON body. Add `store`
|
|
57
|
+
or `name` to title the history item and mark it as saved. Raw query execution is
|
|
58
|
+
rejected with HTTP `403` when the target database is marked read-only.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
curl \
|
|
62
|
+
-H "Authorization: Bearer shub_..." \
|
|
63
|
+
-H "Content-Type: application/json" \
|
|
64
|
+
-d '{"databaseId":"DATABASE_ID","sql":"SELECT * FROM companies LIMIT 10","name":"Company Sample"}' \
|
|
65
|
+
http://127.0.0.1:4173/api/v1/query
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Row lookup accepts a scalar key or a composite primary-key object:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{ "key": 42 }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{ "key": { "id": 42, "locale": "en" } }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`POST /api/v1/databases/:databaseId/tables/:tableName/types` generates
|
|
79
|
+
application types from the declared SQLite schema. It is read-only, uses the
|
|
80
|
+
same generation service as the Structure Inspector and CLI, and returns code as
|
|
81
|
+
JSON without writing server-side files.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
curl \
|
|
85
|
+
-X POST \
|
|
86
|
+
-H "Authorization: Bearer shub_..." \
|
|
87
|
+
-H "Content-Type: application/json" \
|
|
88
|
+
-d '{
|
|
89
|
+
"target": "typescript",
|
|
90
|
+
"options": {
|
|
91
|
+
"propertyNaming": "camel",
|
|
92
|
+
"nullableMode": "native",
|
|
93
|
+
"includeComments": true
|
|
94
|
+
}
|
|
95
|
+
}' \
|
|
96
|
+
http://127.0.0.1:4173/api/v1/databases/DATABASE_ID/tables/users/types
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Supported targets are `typescript`, `rust`, `kotlin`, and `swift`. Warnings are
|
|
100
|
+
returned in the top-level `warnings` array. Metadata includes column counts and
|
|
101
|
+
CHECK-constraint counts.
|
|
102
|
+
|
|
103
|
+
Successful responses use this envelope:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"success": true,
|
|
108
|
+
"message": "",
|
|
109
|
+
"data": {},
|
|
110
|
+
"metadata": {},
|
|
111
|
+
"warnings": []
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Errors use the same envelope with `success: false` and a structured `error`
|
|
116
|
+
object containing `code`, `message`, `details`, and `sqliteCode`.
|
|
117
|
+
|
|
118
|
+
## Example
|
|
119
|
+
|
|
120
|
+
See [`examples/api/list-tables.js`](../examples/api/list-tables.js) for a small
|
|
121
|
+
Node.js example using a token from the `SQLITE_HUB_API_TOKEN` environment
|
|
122
|
+
variable.
|
package/docs/CLI.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
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
|
+
## Start The App
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
sqlite-hub # start on default port 4173
|
|
11
|
+
sqlite-hub --port:4174 # start on a custom port
|
|
12
|
+
sqlite-hub --open # open SQLite Hub in the browser
|
|
13
|
+
sqlite-hub --info # show port, URL, versions, and update status
|
|
14
|
+
sqlite-hub --help # show help text
|
|
15
|
+
sqlite-hub --version # show version number
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`--config` is still accepted as a legacy alias for `--info`.
|
|
19
|
+
|
|
20
|
+
## Databases
|
|
21
|
+
|
|
22
|
+
List all imported databases:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
sqlite-hub --database
|
|
26
|
+
sqlite-hub -d
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The database list shows the name, file path, file size, last opened timestamp,
|
|
30
|
+
and read-only status for databases that have been opened in SQLite Hub.
|
|
31
|
+
|
|
32
|
+
Query details for one database by name or id:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
sqlite-hub --database:Billly --path # get the file path
|
|
36
|
+
sqlite-hub --database:Billly --size # get the file size
|
|
37
|
+
sqlite-hub --database:Billly --lastopened # get last opened timestamp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
List all tables in a database:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
sqlite-hub --database:Billly --tables
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Inspect one table:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
sqlite-hub --database:Billly --table:companies
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Table inspection prints metadata such as columns, primary keys, foreign keys,
|
|
53
|
+
indexes, row count, and row identity strategy.
|
|
54
|
+
|
|
55
|
+
Generate application types from a table schema:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
sqlite-hub --database:Unit-00 --table:users --types:typescript
|
|
59
|
+
sqlite-hub --database:Unit-00 --table:users --types:rust
|
|
60
|
+
sqlite-hub --database:Unit-00 --table:users --types:typescript --json
|
|
61
|
+
sqlite-hub --database:Unit-00 --table:users --types:typescript --output:User.ts
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Aliases are available for common targets: `ts`, `rs`, and `kt`. Without
|
|
65
|
+
`--output` or `--json`, the CLI writes only generated code to stdout so shell
|
|
66
|
+
redirection works cleanly. Warnings are written to stderr. Use `--force` to
|
|
67
|
+
overwrite an existing output file.
|
|
68
|
+
|
|
69
|
+
## SQL Editor
|
|
70
|
+
|
|
71
|
+
Execute raw SQL through the same SQL Editor execution path used by the app:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
sqlite-hub --database:Unit-00 --query:"SELECT * FROM companies LIMIT 10"
|
|
75
|
+
sqlite-hub --database:Unit-00 --query:"SELECT * FROM companies LIMIT 10" --store:"Company Sample"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Raw CLI queries are recorded in Query History. Add `--store:"name"` to title the
|
|
79
|
+
history item and mark it as saved. Raw SQL execution is rejected when the target
|
|
80
|
+
database is marked read-only.
|
|
81
|
+
|
|
82
|
+
List all saved queries for a database:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
sqlite-hub --database:Unit-00 --queries
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Execute a specific saved query by name:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
sqlite-hub --database:Unit-00 --execute:"15min Posting Buckets without id 96"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This searches the query history for the selected database, finds the matching
|
|
95
|
+
saved query by title, executes it, and returns results with metadata such as row
|
|
96
|
+
count, columns, timing, and data.
|
|
97
|
+
|
|
98
|
+
Show the saved query SQL without executing it:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
sqlite-hub --database:Unit-00 --saved-query:"Stock Winners"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Show the saved notes for a query:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
sqlite-hub --database:Unit-00 --notes:"TOP25 Loser and Winner EOD, T1, T3, T5"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Export a saved query using the same CSV, TSV, Markdown, and JSON export logic as
|
|
111
|
+
the SQL Editor:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:csv
|
|
115
|
+
sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:tsv
|
|
116
|
+
sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:md
|
|
117
|
+
sqlite-hub --database:Unit-00 --export:"Stock Winners" --format:json
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The export is written to the current working directory using the generated query
|
|
121
|
+
export filename.
|
|
122
|
+
|
|
123
|
+
## Documents
|
|
124
|
+
|
|
125
|
+
List all Markdown documents stored for a database:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
sqlite-hub --database:Unit-00 --documents
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Print one document's Markdown content:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
sqlite-hub --database:Unit-00 --documents:"Research Notes"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Export one document as a `.md` file into the current working directory:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
sqlite-hub --database:Unit-00 --documents:"Research Notes" --export
|
|
141
|
+
sqlite-hub --database:Unit-00 --documents:"Research Notes--export"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Documents can be matched by id, filename, title, or a partial filename/title
|
|
145
|
+
match.
|
|
146
|
+
|
|
147
|
+
## Row JSON Export
|
|
148
|
+
|
|
149
|
+
Export a single row as JSON by primary key or rowid, using the same row-shaping
|
|
150
|
+
logic as the Row Editor:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
sqlite-hub --database:Unit-00 --table:companies --export:0a754aba373d34972998792a0be4333c
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Available Flags
|
|
157
|
+
|
|
158
|
+
| Flag | Description |
|
|
159
|
+
| --------------------------------------------------------------- | ----------------------------------------------- |
|
|
160
|
+
| `--help`, `-h` | Show help text |
|
|
161
|
+
| `--version`, `-v` | Show version number |
|
|
162
|
+
| `--info` | Show port, URL, versions, and update status |
|
|
163
|
+
| `--open` | Open SQLite Hub in the browser |
|
|
164
|
+
| `--port:PORT` | Start the server on a custom port |
|
|
165
|
+
| `--database`, `-d` | List all imported databases |
|
|
166
|
+
| `--database:name` | Select a database by name or id |
|
|
167
|
+
| `--database:name --path` | Get the file path of a database |
|
|
168
|
+
| `--database:name --size` | Get the size of a database |
|
|
169
|
+
| `--database:name --lastopened` | Get the last opened timestamp |
|
|
170
|
+
| `--database:name --tables` | Get all table names from a database |
|
|
171
|
+
| `--database:name --queries` | List saved queries for a database |
|
|
172
|
+
| `--database:name --query:"sql"` | Execute raw SQL and record it in Query History |
|
|
173
|
+
| `--database:name --query:"sql" --store:"name"` | Save a raw query in Query History with a name |
|
|
174
|
+
| `--database:name --execute:"query"` | Execute a saved query by name |
|
|
175
|
+
| `--database:name --saved-query:"query"` | Print a saved query by name |
|
|
176
|
+
| `--database:name --notes:"query"` | Print saved notes for a query |
|
|
177
|
+
| `--database:name --export:"query" --format:csv\|tsv\|md\|json` | Set query export format |
|
|
178
|
+
| `--database:name --documents` | List Markdown documents for a database |
|
|
179
|
+
| `--database:name --documents:"document"` | Print a document's Markdown content |
|
|
180
|
+
| `--database:name --documents:"document" --export` | Export a document as Markdown |
|
|
181
|
+
| `--database:name --table:"table"` | Print table metadata |
|
|
182
|
+
| `--database:name --table:"table" --export:"pk"` | Export one row as JSON |
|
|
183
|
+
| `--database:name --table:"table" --types:typescript\|ts\|rust\|rs\|kotlin\|kt\|swift` | Generate application types |
|
|
184
|
+
| `--type-name:"name"` | Override generated type name |
|
|
185
|
+
| `--naming:preserve\|camel\|pascal\|snake` | Select property naming |
|
|
186
|
+
| `--nullable:native\|optional` | Select nullable handling |
|
|
187
|
+
| `--comments` | Include schema comments |
|
|
188
|
+
| `--defaults-as-comments` | Include default values as comments |
|
|
189
|
+
| `--json-type:unknown\|record\|json-value` | Select TypeScript JSON mapping |
|
|
190
|
+
| `--include-generated` | Include generated columns |
|
|
191
|
+
| `--include-hidden` | Include hidden columns |
|
|
192
|
+
| `--output:"file"` | Write generated types to a file |
|
|
193
|
+
| `--json` | Print generated type result as JSON |
|
|
194
|
+
| `--force` | Overwrite existing `--output` file |
|
|
195
|
+
|
|
196
|
+
Legacy aliases such as `--config`, `--database-path:name`,
|
|
197
|
+
`--database-size:name`, `--database-lastopened:name`, `--database-tables:name`,
|
|
198
|
+
and `--database:name --sqleditor:"query"` still work.
|
|
199
|
+
|
|
200
|
+
## Example
|
|
201
|
+
|
|
202
|
+
Saved queries created in the graphical SQL Editor can also be executed through
|
|
203
|
+
the CLI. To execute one, run:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
sqlite-hub --database:Unit-00 --execute:"Group by creation Year"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Example output:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
Executing: Group by creation Year
|
|
213
|
+
SQL: SELECT STRFTIME('%Y', creation_time, 'unixepoch') AS creation_year, COUNT(*) AS channel_count FROM channels WHERE creation_time IS NOT NU...
|
|
214
|
+
------------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
Statement count: 1
|
|
217
|
+
Timing: 1ms
|
|
218
|
+
|
|
219
|
+
Statement 1 (resultSet):
|
|
220
|
+
Rows: 3
|
|
221
|
+
Columns: creation_year, channel_count
|
|
222
|
+
|
|
223
|
+
Results:
|
|
224
|
+
[0] 2024 | 11
|
|
225
|
+
[1] 2025 | 47
|
|
226
|
+
[2] 2026 | 40
|
|
227
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# SQLite Hub UI Rules for Codex
|
|
2
|
+
|
|
3
|
+
Follow these rules exactly when creating or modifying UI controls.
|
|
4
|
+
|
|
5
|
+
1. Reuse existing shared components before creating anything new.
|
|
6
|
+
2. Use exactly one semantic main class per control.
|
|
7
|
+
3. Never combine multiple primary button-style classes (`standard-button`, `signature-button`, `delete-button`) on the same element.
|
|
8
|
+
4. View-specific classes may change layout, width, spacing, or position only.
|
|
9
|
+
5. View-specific classes must not redefine the base style of shared components.
|
|
10
|
+
6. The standard height for buttons and compact interactive controls is `32px`.
|
|
11
|
+
7. The source of truth for button height is `--button-height` in `frontend/styles/tokens.css`.
|
|
12
|
+
8. The source of truth for form control height is `--control-height` in `frontend/styles/tokens.css`.
|
|
13
|
+
9. Controls in the same row must have the same height unless one is a text input or textarea.
|
|
14
|
+
10. All regular buttons must use one of these base classes only: `standard-button`, `signature-button`, `delete-button`.
|
|
15
|
+
11. Use `standard-button` for normal actions.
|
|
16
|
+
12. Use `signature-button` only for the primary yellow CTA in a context.
|
|
17
|
+
13. Use `delete-button` only for destructive actions.
|
|
18
|
+
14. Delete buttons must show the `delete` Material Symbol before the text label.
|
|
19
|
+
15. `signature-button` must keep its hover state and chamfered corner.
|
|
20
|
+
16. All visible clickable buttons must have a hover state.
|
|
21
|
+
17. Disabled states must come from the shared component, not from local view CSS.
|
|
22
|
+
18. Dropdown toggles may combine a base button class with `dropdown-button__toggle`; that class may only control dropdown layout and open-state behavior.
|
|
23
|
+
19. Visibility/toggle buttons may combine a base button class with `panel-toggle-button`; that class is the shared toggle-state modifier.
|
|
24
|
+
20. All reusable checkboxes must use `standard-checkbox`.
|
|
25
|
+
21. Do not build feature-specific checkbox shells or checkbox base styles.
|
|
26
|
+
22. Inputs and selects must follow the shared base rules in `frontend/styles/base.css`.
|
|
27
|
+
23. Ghost or transparent inputs must not use a white background, including unfocused state.
|
|
28
|
+
24. When a new control pattern appears in multiple places, promote it to a shared component first, then migrate existing usages.
|
|
29
|
+
|
|
30
|
+
## Source of Truth
|
|
31
|
+
|
|
32
|
+
- `frontend/styles/tokens.css`
|
|
33
|
+
- `frontend/styles/base.css`
|
|
34
|
+
- `frontend/index.html`
|
|
35
|
+
|
|
36
|
+
## Default Decision Rules
|
|
37
|
+
|
|
38
|
+
- Prefer reuse over invention.
|
|
39
|
+
- Prefer migration over local override.
|
|
40
|
+
- Prefer shared component updates over per-view fixes.
|
|
41
|
+
|
|
42
|
+
## History elements
|
|
43
|
+
|
|
44
|
+
- Query history panels, such as SQL Editor and Charts history, are always placed on the right side.
|
|
45
|
+
- Subnavigation panels, such as tables, documents, structure objects, and table-designer tables, are always placed on the left side.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# v1.4.0
|
|
2
|
+
|
|
3
|
+
- Schema Diff / Database Diff
|
|
4
|
+
|
|
5
|
+
# v1.3.0
|
|
6
|
+
|
|
7
|
+
- remove unused css and duplicates, css code rework
|
|
8
|
+
- UX Audit from @corneliakocher
|
|
9
|
+
- edit name and notes for backup
|
|
10
|
+
- generate types from schema to typescript, kotlin, rust, swift
|
|
11
|
+
- open row editor drawer with id hash http://127.0.0.1:4180/#/data#14a06a1ffa23e08ae86becec0c5d8b38
|
|
12
|
+
|
|
13
|
+
# v1.1.2
|
|
14
|
+
|
|
15
|
+
- documents overhaul
|
|
16
|
+
- introducing the SQLite Hub dropdown button
|
|
17
|
+
- backup manager
|
|
18
|
+
|
|
19
|
+
# v1.1.1
|
|
20
|
+
|
|
21
|
+
- table designer overhaul
|
|
22
|
+
|
|
23
|
+
# v1.1.0
|
|
24
|
+
|
|
25
|
+
- making the UI more consistent
|
|
26
|
+
- structure overhaul, better UI
|
|
27
|
+
- chart overhaul, better UI, search, etz
|
|
28
|
+
- store last position of structure
|
|
29
|
+
- join preview in structure
|
|
30
|
+
- export JSON for Data, SQL Editor
|
|
31
|
+
- export parquet for Data, SQL Editor
|
|
32
|
+
- check updates for new versions in settings
|
|
33
|
+
- Global Database Search
|
|
34
|
+
|
|
35
|
+
# v1.0.0
|
|
36
|
+
|
|
37
|
+
- Removed external Tailwind.
|
|
38
|
+
- Fixed vibe-coding issues with https://github.com/oliverjessner/ItWorksBut.
|
|
39
|
+
- Persisted saved/recent chart tabs in localStorage.
|
|
40
|
+
- Updated dependencies.
|
|
41
|
+
- Replaced innerHTML with DOM functions.
|
|
42
|
+
- Display execution time in seconds when it exceeds 10 seconds.
|
|
43
|
+
- The Performance panel in the SQL Editor shows query memory size.
|
|
44
|
+
- The Structure view remembers the last selected table.
|
|
45
|
+
- Removed pixel shift bug in SQL Editor on the bottom cards
|
|
46
|
+
- title name changing depending on the menu
|
|
47
|
+
- in messages you can see your executed query
|
|
48
|
+
- secure execute for destructive queries
|
|
49
|
+
- 250 page size, advanced search in data
|
|
50
|
+
- export TSV, CSV, markdown, duplicate as table
|
|
51
|
+
- copy from and export column function, with separator and wrapper
|
|
52
|
+
- quick picks for database
|
|
53
|
+
- export row as json
|
|
54
|
+
- row editor shows urls and opens in browser, path detection, timestamp detection
|
|
55
|
+
- format button in SQLEditor
|
|
56
|
+
- API
|
|
57
|
+
|
|
58
|
+
# v0.9.3
|
|
59
|
+
|
|
60
|
+
- Improved re-rendering.
|
|
61
|
+
- Fixed the sorting bug in Charts.
|
|
62
|
+
- Stored the data row size in localStorage.
|
|
63
|
+
- Saved charts.
|
|
64
|
+
|
|
65
|
+
# v0.9.1
|
|
66
|
+
|
|
67
|
+
- Tagging queue improvements.
|
|
68
|
+
- Rotate right and rotate left.
|
|
69
|
+
|
|
70
|
+
# v0.9.0
|
|
71
|
+
|
|
72
|
+
- Tagging view.
|
|
73
|
+
- Filtered Create, Update, and Delete queries out of the chart section.
|
|
74
|
+
|
|
75
|
+
# v0.8.8
|
|
76
|
+
|
|
77
|
+
- Fixed the delete-query modal window.
|
|
78
|
+
- CSV export filenames are based on query names.
|
|
79
|
+
- Unsaved query history tab.
|
|
80
|
+
|
|
81
|
+
# v0.8.7
|
|
82
|
+
|
|
83
|
+
- UX fixes.
|
|
84
|
+
- Fixed a lot of vibe slop.
|
|
85
|
+
- Started building reusable components.
|
|
86
|
+
|
|
87
|
+
# v0.8.0
|
|
88
|
+
|
|
89
|
+
- DDL copy button.
|
|
90
|
+
- Open in Charts button in query details.
|
|
91
|
+
- Clear makes the editor active.
|
|
92
|
+
- UI fixes.
|
|
93
|
+
- Overview improvements.
|
|
94
|
+
|
|
95
|
+
# v0.7.0
|
|
96
|
+
|
|
97
|
+
- Hide Query History and Hide Editor controls.
|
|
98
|
+
- Better CLI interface.
|
|
99
|
+
- Plotting and graphs.
|
|
100
|
+
- Removed UI inconsistencies.
|
|
101
|
+
|
|
102
|
+
# v0.6.0
|
|
103
|
+
|
|
104
|
+
- Table Designer: create tables in SQLite Hub.
|
|
105
|
+
|
|
106
|
+
# v0.5.1
|
|
107
|
+
|
|
108
|
+
- Bug fix in the SQL Editor.
|
|
109
|
+
|
|
110
|
+
# v0.5.0
|
|
111
|
+
|
|
112
|
+
- SQL query history.
|
|
113
|
+
- Open in Finder from Overview.
|
|
114
|
+
- Sort columns in Data and the SQL Editor.
|
|
115
|
+
- JSON view in the row editor.
|
|
116
|
+
|
|
117
|
+
# v0.4.0
|
|
118
|
+
|
|
119
|
+
- Search in Data.
|
|
120
|
+
- Shift + Enter.
|
|
121
|
+
- Database logos.
|
|
122
|
+
- Cleaned up some chaotic code.
|
|
123
|
+
|
|
124
|
+
# v0.3.2
|
|
125
|
+
|
|
126
|
+
- Delete rows.
|
|
127
|
+
- Modal windows for rows.
|
|
128
|
+
|
|
129
|
+
# v0.3.1
|
|
130
|
+
|
|
131
|
+
- Visualize tables.
|
|
132
|
+
- Export CSV from Data and the SQL Editor.
|
|
133
|
+
- Backup mode.
|
|
134
|
+
|
|
135
|
+
# v0.2.0
|
|
136
|
+
|
|
137
|
+
- Database fix.
|
|
138
|
+
|
|
139
|
+
# v0.1.3
|
|
140
|
+
|
|
141
|
+
- Edit in the SQL Editor.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Meddia Tagging
|
|
2
|
+
|
|
3
|
+
## tagging queue
|
|
4
|
+
|
|
5
|
+
`shift + enter` triggers tagged & next
|
|
6
|
+
|
|
7
|
+
# SQL Editor
|
|
8
|
+
|
|
9
|
+
`shift + enter` triggers execute
|
|
10
|
+
|
|
11
|
+
## Chart Details & Query Details (drawer)
|
|
12
|
+
|
|
13
|
+
`esc` closes the drawer
|
|
14
|
+
|
|
15
|
+
# Misc
|
|
16
|
+
|
|
17
|
+
## Modals
|
|
18
|
+
|
|
19
|
+
`esc` closes the modal
|
|
20
|
+
|
|
21
|
+
## Input elements
|
|
22
|
+
|
|
23
|
+
`esc` clears the input
|
|
24
|
+
|
|
25
|
+
## Dropdown Buttons
|
|
26
|
+
|
|
27
|
+
`esc` closes the dropwdown
|
package/docs/todo.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Maybe
|
|
2
|
+
|
|
3
|
+
- MCP
|
|
4
|
+
- query perf, history, api history
|
|
5
|
+
- Data Pipeline Light/hook
|
|
6
|
+
- Query Results as persistent Artifacts
|
|
7
|
+
- SDK?
|
|
8
|
+
- FTS5 Manager
|
|
9
|
+
- Synthetic Data Generator
|
|
10
|
+
- programmable triggers?
|
|
11
|
+
- Query/Scheme Analyzer mit Explain Query Plan
|
|
12
|
+
- MD to pdf
|
|
13
|
+
- Color update / Customization
|
|
14
|
+
- hide media tagging / backups / overview
|
|
15
|
+
- change accent color
|
|
16
|
+
- toast position
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const SQLITE_HUB_URL = process.env.SQLITE_HUB_URL || 'http://127.0.0.1:4173';
|
|
2
|
+
const apiToken = process.env.SQLITE_HUB_API_TOKEN;
|
|
3
|
+
const databaseId = process.env.SQLITE_HUB_DATABASE_ID || process.argv[2];
|
|
4
|
+
const tableName = process.env.SQLITE_HUB_TABLE || process.argv[3] || 'users';
|
|
5
|
+
const target = process.env.SQLITE_HUB_TYPE_TARGET || process.argv[4] || 'typescript';
|
|
6
|
+
|
|
7
|
+
if (!apiToken) {
|
|
8
|
+
throw new Error('SQLITE_HUB_API_TOKEN is required.');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (!databaseId) {
|
|
12
|
+
throw new Error('Provide SQLITE_HUB_DATABASE_ID or pass the database id as the first argument.');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const url = [
|
|
16
|
+
SQLITE_HUB_URL.replace(/\/$/, ''),
|
|
17
|
+
'api/v1/databases',
|
|
18
|
+
encodeURIComponent(databaseId),
|
|
19
|
+
'tables',
|
|
20
|
+
encodeURIComponent(tableName),
|
|
21
|
+
'types',
|
|
22
|
+
].join('/');
|
|
23
|
+
|
|
24
|
+
const response = await fetch(url, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: 'application/json',
|
|
28
|
+
Authorization: `Bearer ${apiToken}`,
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
target,
|
|
33
|
+
options: {
|
|
34
|
+
propertyNaming: 'camel',
|
|
35
|
+
nullableMode: 'native',
|
|
36
|
+
includeComments: true,
|
|
37
|
+
includeDefaultsAsComments: true,
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const payload = await response.json();
|
|
43
|
+
|
|
44
|
+
if (!response.ok || !payload.success) {
|
|
45
|
+
throw new Error(payload.error?.message || payload.message || 'Type generation failed.');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.log(payload.data.code);
|
|
49
|
+
|
|
50
|
+
if (payload.warnings?.length) {
|
|
51
|
+
console.error(payload.warnings.map(warning => `Warning: ${warning}`).join('\n'));
|
|
52
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|