sqlite-hub 1.1.0 → 1.1.2

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 (58) hide show
  1. package/README.md +17 -196
  2. package/bin/sqlite-hub.js +7 -2
  3. package/frontend/js/api.js +60 -0
  4. package/frontend/js/app.js +140 -10
  5. package/frontend/js/components/dropdownButton.js +92 -0
  6. package/frontend/js/components/modal.js +991 -876
  7. package/frontend/js/components/queryEditor.js +29 -18
  8. package/frontend/js/components/queryHistoryDetail.js +20 -1
  9. package/frontend/js/components/queryHistoryHeader.js +3 -2
  10. package/frontend/js/components/rowEditorPanel.js +1 -0
  11. package/frontend/js/components/sidebar.js +1 -0
  12. package/frontend/js/components/structureGraph.js +1 -0
  13. package/frontend/js/components/tableDesignerEditor.js +23 -42
  14. package/frontend/js/components/tableDesignerSidebar.js +7 -31
  15. package/frontend/js/components/tableDesignerSqlPreview.js +2 -1
  16. package/frontend/js/router.js +2 -0
  17. package/frontend/js/store.js +407 -38
  18. package/frontend/js/utils/riskySql.js +165 -0
  19. package/frontend/js/views/backups.js +176 -0
  20. package/frontend/js/views/charts.js +12 -11
  21. package/frontend/js/views/data.js +37 -35
  22. package/frontend/js/views/documents.js +231 -162
  23. package/frontend/js/views/mediaTagging.js +6 -5
  24. package/frontend/js/views/structure.js +47 -43
  25. package/frontend/js/views/tableDesigner.js +45 -1
  26. package/frontend/styles/components.css +237 -59
  27. package/frontend/styles/structure-graph.css +10 -2
  28. package/frontend/styles/tailwind.generated.css +1 -1
  29. package/frontend/styles/tokens.css +2 -0
  30. package/frontend/styles/views.css +84 -41
  31. package/package.json +2 -1
  32. package/server/routes/backups.js +120 -0
  33. package/server/routes/connections.js +26 -3
  34. package/server/routes/externalApi.js +6 -2
  35. package/server/server.js +3 -1
  36. package/server/services/databaseCommandService.js +4 -3
  37. package/server/services/sqlite/backupService.js +497 -66
  38. package/server/services/sqlite/connectionManager.js +2 -2
  39. package/server/services/sqlite/dataBrowserService.js +11 -3
  40. package/server/services/sqlite/importService.js +25 -0
  41. package/server/services/sqlite/sqlExecutor.js +2 -0
  42. package/server/services/storage/appStateStore.js +379 -88
  43. package/tests/api-token-auth.test.js +45 -2
  44. package/tests/backup-manager.test.js +140 -0
  45. package/tests/backups-view.test.js +64 -0
  46. package/tests/charts-height-preset-storage.test.js +60 -0
  47. package/tests/charts-route-state.test.js +144 -0
  48. package/tests/cli-service-delegation.test.js +97 -0
  49. package/tests/connection-removal.test.js +52 -0
  50. package/tests/database-command-service.test.js +38 -3
  51. package/tests/documents-view.test.js +132 -0
  52. package/tests/dropdown-button.test.js +75 -0
  53. package/tests/query-editor.test.js +28 -0
  54. package/tests/query-history-detail.test.js +37 -0
  55. package/tests/query-history-header.test.js +30 -0
  56. package/tests/risky-sql.test.js +30 -0
  57. package/tests/row-editor-null-values.test.js +24 -0
  58. package/tests/structure-view.test.js +56 -0
@@ -0,0 +1,92 @@
1
+ import { escapeHtml } from "../utils/format.js";
2
+
3
+ function renderDataAttributes(attributes = {}) {
4
+ return Object.entries(attributes)
5
+ .filter(([, value]) => value !== undefined && value !== null && value !== false)
6
+ .map(([key, value]) => {
7
+ const attributeName = key
8
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
9
+ .replace(/_/g, "-")
10
+ .toLowerCase();
11
+
12
+ return value === true
13
+ ? `data-${attributeName}`
14
+ : `data-${attributeName}="${escapeHtml(value)}"`;
15
+ })
16
+ .join(" ");
17
+ }
18
+
19
+ function renderDropdownItem(item = {}) {
20
+ const dataAttributes = renderDataAttributes(item.dataAttributes);
21
+ const actionAttribute = item.actionAttribute || "data-action";
22
+ const actionMarkup =
23
+ item.action === undefined || item.action === null
24
+ ? ""
25
+ : `${escapeHtml(actionAttribute)}="${escapeHtml(item.action)}"`;
26
+ const disabled = item.disabled ? 'disabled aria-disabled="true"' : "";
27
+ const iconMarkup = item.icon
28
+ ? `<span class="material-symbols-outlined">${escapeHtml(item.icon)}</span>`
29
+ : "";
30
+
31
+ return `
32
+ <button
33
+ class="dropdown-button__item ${item.danger ? "dropdown-button__item--danger" : ""}"
34
+ ${actionMarkup}
35
+ ${dataAttributes}
36
+ ${disabled}
37
+ role="menuitem"
38
+ type="button"
39
+ >
40
+ ${iconMarkup}
41
+ <span>${escapeHtml(item.label)}</span>
42
+ </button>
43
+ `;
44
+ }
45
+
46
+ export function renderDropdownButton({
47
+ align = "right",
48
+ disabled = false,
49
+ icon = "more_horiz",
50
+ items = [],
51
+ label,
52
+ title = label,
53
+ } = {}) {
54
+ const iconMarkup = icon
55
+ ? `<span class="material-symbols-outlined">${escapeHtml(icon)}</span>`
56
+ : "";
57
+ const buttonLabel = escapeHtml(label);
58
+ const chevron = '<span class="material-symbols-outlined dropdown-button__chevron">expand_more</span>';
59
+
60
+ if (disabled) {
61
+ return `
62
+ <button
63
+ aria-disabled="true"
64
+ class="standard-button dropdown-button__toggle"
65
+ disabled
66
+ title="${escapeHtml(title)}"
67
+ type="button"
68
+ >
69
+ ${iconMarkup}
70
+ ${buttonLabel}
71
+ ${chevron}
72
+ </button>
73
+ `;
74
+ }
75
+
76
+ return `
77
+ <details class="dropdown-button dropdown-button--align-${escapeHtml(align)}" data-dropdown-button>
78
+ <summary
79
+ aria-label="${escapeHtml(title)}"
80
+ class="standard-button dropdown-button__toggle"
81
+ title="${escapeHtml(title)}"
82
+ >
83
+ ${iconMarkup}
84
+ ${buttonLabel}
85
+ ${chevron}
86
+ </summary>
87
+ <div class="dropdown-button__panel" role="menu">
88
+ ${items.map((item) => renderDropdownItem(item)).join("")}
89
+ </div>
90
+ </details>
91
+ `;
92
+ }