@adecore/database 0.62.1 → 0.63.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 (231) hide show
  1. package/README.md +1 -1
  2. package/dist/DatabaseProvider.d.ts +1 -1
  3. package/dist/client/types.js +0 -1
  4. package/dist/client-context.d.ts +3 -2
  5. package/dist/connections/EngineIcon.d.ts +2 -1
  6. package/dist/connections/docker.js +0 -3
  7. package/dist/connections/use-docker-containers.d.ts +2 -1
  8. package/dist/console/DestructiveDialog.d.ts +2 -1
  9. package/dist/console/HistoryPanel.d.ts +2 -1
  10. package/dist/console/QueryConsole.js +0 -3
  11. package/dist/console/SchemaPicker.d.ts +2 -1
  12. package/dist/console/StatementResultView.d.ts +2 -1
  13. package/dist/console/TransactionControls.d.ts +2 -1
  14. package/dist/console/labels.js +0 -1
  15. package/dist/console/useConsoleHistory.d.ts +2 -1
  16. package/dist/ddl/alter-sqlite.js +0 -1
  17. package/dist/ddl/alter.js +0 -1
  18. package/dist/ddl/column.d.ts +2 -1
  19. package/dist/ddl/column.js +0 -1
  20. package/dist/ddl/create.d.ts +2 -1
  21. package/dist/ddl/create.js +0 -2
  22. package/dist/ddl/dialect.js +0 -1
  23. package/dist/ddl/diff.d.ts +4 -3
  24. package/dist/ddl/diff.js +0 -3
  25. package/dist/ddl/draft.js +0 -2
  26. package/dist/ddl/parse.js +0 -4
  27. package/dist/designer/ColumnsEditor.js +0 -1
  28. package/dist/designer/DesignerView.js +0 -1
  29. package/dist/designer/ForeignKeysEditor.d.ts +2 -1
  30. package/dist/designer/NamePicker.d.ts +2 -1
  31. package/dist/designer/SqlPreview.d.ts +2 -1
  32. package/dist/designer/SqlPreview.js +0 -2
  33. package/dist/designer/TableDesigner.js +0 -1
  34. package/dist/designer/edit.js +0 -1
  35. package/dist/designer/plan.js +0 -1
  36. package/dist/explorer/DatabaseExplorer.js +0 -1
  37. package/dist/explorer/RowMenu.d.ts +2 -1
  38. package/dist/explorer/TableDialog.d.ts +2 -1
  39. package/dist/explorer/tree.d.ts +11 -13
  40. package/dist/explorer/tree.js +3 -16
  41. package/dist/explorer/use-explorer-loads.d.ts +2 -1
  42. package/dist/explorer/use-explorer-loads.js +0 -2
  43. package/dist/explorer/use-stored-expansion.d.ts +1 -1
  44. package/dist/grid/CellEditor.d.ts +2 -1
  45. package/dist/grid/CellEditor.js +0 -1
  46. package/dist/grid/CopyAsMenu.d.ts +2 -1
  47. package/dist/grid/DataGrid.js +1 -1
  48. package/dist/grid/EnumPicker.d.ts +2 -1
  49. package/dist/grid/GridHeaderCell.js +0 -3
  50. package/dist/grid/GridRowView.d.ts +3 -2
  51. package/dist/grid/GridRowView.js +1 -0
  52. package/dist/grid/ValueDock.d.ts +2 -3
  53. package/dist/grid/ValueDock.js +2 -3
  54. package/dist/grid/aggregates.d.ts +2 -1
  55. package/dist/grid/cell-range.d.ts +2 -1
  56. package/dist/grid/cell-range.js +0 -2
  57. package/dist/grid/column-layout.d.ts +2 -1
  58. package/dist/grid/column-layout.js +0 -1
  59. package/dist/grid/column-selection.js +0 -1
  60. package/dist/grid/column-view.js +0 -2
  61. package/dist/grid/copy-formats.d.ts +2 -1
  62. package/dist/grid/display.d.ts +3 -2
  63. package/dist/grid/display.js +0 -5
  64. package/dist/grid/edit-value.js +0 -1
  65. package/dist/grid/enum-type.js +0 -1
  66. package/dist/grid/focused-value.js +0 -1
  67. package/dist/grid/layout.d.ts +2 -2
  68. package/dist/grid/layout.js +1 -9
  69. package/dist/grid/navigation.d.ts +2 -1
  70. package/dist/grid/navigation.js +0 -1
  71. package/dist/grid/row-selection.d.ts +3 -2
  72. package/dist/grid/sort.js +0 -2
  73. package/dist/grid/types.js +0 -1
  74. package/dist/grid/whole-cells.d.ts +2 -1
  75. package/dist/host/helper-path.d.ts +1 -0
  76. package/dist/host/helper-path.js +3 -1
  77. package/dist/host/host.js +0 -4
  78. package/dist/host/index.d.ts +1 -1
  79. package/dist/host/index.js +1 -1
  80. package/dist/host/spawn.js +0 -1
  81. package/dist/index.d.ts +1 -1
  82. package/dist/number-notation.d.ts +1 -0
  83. package/dist/number-notation.js +1 -0
  84. package/dist/sql-split.d.ts +3 -2
  85. package/dist/structure/StructureView.js +0 -1
  86. package/dist/table/CommandField.d.ts +2 -1
  87. package/dist/table/ImportDialog.d.ts +2 -1
  88. package/dist/table/ImportDialog.js +0 -3
  89. package/dist/{grid → table}/RecordView.d.ts +3 -2
  90. package/dist/{grid → table}/RecordView.js +5 -6
  91. package/dist/table/TableStatusBar.d.ts +2 -1
  92. package/dist/table/TableStatusBar.js +0 -1
  93. package/dist/table/TableToolbar.d.ts +2 -1
  94. package/dist/table/TableToolbar.js +0 -1
  95. package/dist/table/TableView.d.ts +0 -1
  96. package/dist/table/TableView.js +2 -3
  97. package/dist/table/command-field.d.ts +4 -5
  98. package/dist/table/command-field.js +2 -11
  99. package/dist/table/grid-rows.d.ts +3 -2
  100. package/dist/table/grid-rows.js +0 -1
  101. package/dist/table/import-mapping.js +0 -2
  102. package/dist/table/layout-store.d.ts +0 -1
  103. package/dist/table/layout-store.js +1 -1
  104. package/dist/table/paging.js +0 -1
  105. package/dist/table/pending.d.ts +1 -2
  106. package/dist/table/pending.js +1 -6
  107. package/dist/table/useStoredLayout.d.ts +2 -2
  108. package/dist/table/useStoredLayout.js +1 -1
  109. package/dist/table/useTableTransfer.d.ts +4 -3
  110. package/dist/table/useTableTransfer.js +0 -2
  111. package/dist/testing/fake.js +0 -3
  112. package/dist/value/ValueEditor.d.ts +2 -1
  113. package/dist/value/ValueEditor.js +0 -4
  114. package/dist/value/ValuePanel.js +0 -1
  115. package/dist/value/draft.d.ts +2 -1
  116. package/dist/value/draft.js +0 -1
  117. package/dist/value/hex.d.ts +2 -2
  118. package/dist/value/hex.js +1 -2
  119. package/dist/value/json.d.ts +2 -1
  120. package/dist/value/json.js +0 -1
  121. package/dist/value/views.d.ts +0 -1
  122. package/dist/value/views.js +1 -3
  123. package/dist/workbench/DatabaseWorkbench.js +0 -2
  124. package/dist/workbench/DesignerTab.d.ts +2 -1
  125. package/dist/workbench/TableTab.d.ts +2 -1
  126. package/dist/workbench/tabs.d.ts +3 -2
  127. package/dist/workbench/tabs.js +0 -3
  128. package/package.json +9 -10
  129. package/src/DatabaseProvider.tsx +1 -1
  130. package/src/client/types.ts +0 -2
  131. package/src/client-context.ts +2 -2
  132. package/src/connections/EngineIcon.tsx +1 -1
  133. package/src/connections/docker.ts +0 -3
  134. package/src/connections/use-docker-containers.ts +1 -1
  135. package/src/console/DestructiveDialog.tsx +1 -1
  136. package/src/console/HistoryPanel.tsx +1 -1
  137. package/src/console/QueryConsole.tsx +0 -3
  138. package/src/console/SchemaPicker.tsx +1 -1
  139. package/src/console/StatementResultView.tsx +1 -1
  140. package/src/console/TransactionControls.tsx +1 -1
  141. package/src/console/destructive.ts +0 -1
  142. package/src/console/labels.ts +0 -1
  143. package/src/console/useConsoleHistory.ts +1 -1
  144. package/src/ddl/alter-sqlite.ts +0 -1
  145. package/src/ddl/alter.ts +0 -1
  146. package/src/ddl/column.ts +1 -2
  147. package/src/ddl/create.ts +1 -3
  148. package/src/ddl/dialect.ts +0 -1
  149. package/src/ddl/diff.ts +3 -6
  150. package/src/ddl/draft.ts +0 -2
  151. package/src/ddl/parse.ts +0 -4
  152. package/src/designer/ColumnsEditor.tsx +0 -2
  153. package/src/designer/DesignerView.tsx +0 -5
  154. package/src/designer/ForeignKeysEditor.tsx +1 -1
  155. package/src/designer/NamePicker.tsx +1 -3
  156. package/src/designer/SqlPreview.tsx +1 -3
  157. package/src/designer/TableDesigner.tsx +0 -2
  158. package/src/designer/edit.ts +0 -2
  159. package/src/designer/editor-props.ts +0 -1
  160. package/src/designer/plan.ts +0 -2
  161. package/src/explorer/DatabaseExplorer.tsx +0 -1
  162. package/src/explorer/RowMenu.tsx +1 -1
  163. package/src/explorer/TableDialog.tsx +1 -1
  164. package/src/explorer/expansion.ts +0 -1
  165. package/src/explorer/table-statements.ts +0 -1
  166. package/src/explorer/tree.ts +13 -31
  167. package/src/explorer/use-explorer-loads.ts +1 -4
  168. package/src/explorer/use-stored-expansion.ts +1 -2
  169. package/src/grid/CellEditor.tsx +1 -2
  170. package/src/grid/CopyAsMenu.tsx +1 -1
  171. package/src/grid/DataGrid.tsx +2 -4
  172. package/src/grid/EnumPicker.tsx +1 -2
  173. package/src/grid/GridHeaderCell.tsx +0 -3
  174. package/src/grid/GridRowView.tsx +3 -4
  175. package/src/grid/ValueDock.tsx +3 -6
  176. package/src/grid/aggregates.ts +1 -2
  177. package/src/grid/cell-range.ts +1 -3
  178. package/src/grid/column-layout.ts +1 -2
  179. package/src/grid/column-selection.ts +0 -1
  180. package/src/grid/column-view.ts +0 -2
  181. package/src/grid/copy-formats.ts +1 -2
  182. package/src/grid/display.ts +2 -9
  183. package/src/grid/edit-value.ts +0 -1
  184. package/src/grid/enum-type.ts +0 -1
  185. package/src/grid/focused-value.ts +0 -1
  186. package/src/grid/layout.ts +2 -12
  187. package/src/grid/navigation.ts +1 -3
  188. package/src/grid/row-selection.ts +2 -2
  189. package/src/grid/sort.ts +0 -2
  190. package/src/grid/types.ts +0 -5
  191. package/src/grid/whole-cells.ts +1 -2
  192. package/src/host/helper-path.ts +4 -1
  193. package/src/host/host.ts +0 -6
  194. package/src/host/index.ts +1 -1
  195. package/src/host/spawn.ts +0 -2
  196. package/src/host/types.ts +0 -3
  197. package/src/index.ts +1 -1
  198. package/src/number-notation.ts +2 -0
  199. package/src/protocol/connection.ts +0 -2
  200. package/src/protocol/errors.ts +0 -3
  201. package/src/protocol/messages.ts +0 -1
  202. package/src/protocol/schema.ts +0 -2
  203. package/src/protocol/values.ts +0 -2
  204. package/src/sql-split.ts +2 -2
  205. package/src/structure/StructureView.tsx +0 -1
  206. package/src/table/CommandField.tsx +1 -1
  207. package/src/table/ImportDialog.tsx +1 -7
  208. package/src/{grid → table}/RecordView.tsx +9 -12
  209. package/src/table/TableStatusBar.tsx +1 -3
  210. package/src/table/TableToolbar.tsx +1 -6
  211. package/src/table/TableView.tsx +2 -4
  212. package/src/table/command-field.ts +5 -14
  213. package/src/table/grid-rows.ts +2 -3
  214. package/src/table/import-mapping.ts +0 -2
  215. package/src/table/layout-store.ts +1 -2
  216. package/src/table/paging.ts +0 -1
  217. package/src/table/pending.ts +2 -9
  218. package/src/table/references.ts +0 -1
  219. package/src/table/useStoredLayout.ts +2 -4
  220. package/src/table/useTableTransfer.ts +3 -8
  221. package/src/testing/fake.ts +0 -5
  222. package/src/value/ValueEditor.tsx +1 -5
  223. package/src/value/ValuePanel.tsx +0 -1
  224. package/src/value/draft.ts +1 -2
  225. package/src/value/hex.ts +2 -3
  226. package/src/value/json.ts +1 -2
  227. package/src/value/views.ts +1 -4
  228. package/src/workbench/DatabaseWorkbench.tsx +0 -2
  229. package/src/workbench/DesignerTab.tsx +1 -2
  230. package/src/workbench/TableTab.tsx +1 -1
  231. package/src/workbench/tabs.ts +2 -7
@@ -12,10 +12,6 @@ import { renderView, sizeOf, viewsOf } from './views.js';
12
12
  const WRAPPING_VIEWS = new Set(['text', 'formatted', 'utf8']);
13
13
  const READING_FRAME = 'flex-1 rounded-lg border border-border bg-surface';
14
14
  const READING = `p-2 ${CODE_TEXT} text-text`;
15
- /*
16
- * The whole of one value, to read and change what a cell is too small for: Text, Formatted for JSON, or
17
- * Hex, Text and UUID for binary, with the checks of JSON and hex before a change is taken.
18
- */
19
15
  export function ValueEditor({ column, value, editable, onCommit }) {
20
16
  const { t } = useTranslation('database');
21
17
  const { name, type, kind } = column;
@@ -4,7 +4,6 @@ import clsx from 'clsx';
4
4
  import { MousePointerClick, X } from 'lucide-react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { ValueEditor } from './ValueEditor.js';
7
- /* The whole value of the focused cell beside the grid, to read and edit what a cell is too small for. */
8
7
  export function ValuePanel({ column, value, loading, editable, onCommit, onClose, className, ref }) {
9
8
  const { t } = useTranslation('database');
10
9
  const ready = column !== null && !loading && value !== undefined;
@@ -20,7 +20,7 @@ export type DraftProblem = {
20
20
  readonly kind: 'hex';
21
21
  readonly problem: HexProblem;
22
22
  };
23
- export type Conversion = {
23
+ type Conversion = {
24
24
  readonly ok: true;
25
25
  readonly value: EditValue;
26
26
  } | {
@@ -31,3 +31,4 @@ export declare const sourceOf: (column: Pick<GridColumn, 'name' | 'type' | 'kind
31
31
  export declare const sameSource: (a: Source, b: Source) => boolean;
32
32
  export declare const sameDraft: (a: Draft, b: Draft) => boolean;
33
33
  export declare const editValueOf: (draft: Draft, source: Source) => Conversion;
34
+ export {};
@@ -1,7 +1,6 @@
1
1
  import { parseDraft } from '../grid/edit-value.js';
2
2
  import { parseHex } from './hex.js';
3
3
  import { checkJson, isJsonDocument } from './json.js';
4
- /* The text a value is edited as: a binary value as its hex, everything else as it is written. */
5
4
  const textOf = (value) => (typeof value === 'object' ? value.hex : String(value));
6
5
  export const sourceOf = (column, value) => {
7
6
  const binary = column.kind === 'binary' || (value !== null && typeof value === 'object');
@@ -1,14 +1,14 @@
1
1
  export type HexProblem = 'characters' | 'odd';
2
- export type ParsedHex = {
2
+ type ParsedHex = {
3
3
  readonly ok: true;
4
4
  readonly hex: string;
5
5
  } | {
6
6
  readonly ok: false;
7
7
  readonly problem: HexProblem;
8
8
  };
9
- export declare const BYTES_PER_LINE = 16;
10
9
  export declare const parseHex: (text: string) => ParsedHex;
11
10
  export declare const bytesOf: (hex: string) => Uint8Array;
12
11
  export declare const decodeUtf8: (hex: string) => string;
13
12
  export declare const formatUuid: (hex: string) => string | null;
14
13
  export declare const hexDumpLines: (hex: string, maxBytes?: number) => string[];
14
+ export {};
package/dist/value/hex.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* Binary values cross as lowercase hex; these turn it into what a person reads and back. */
2
- export const BYTES_PER_LINE = 16;
2
+ const BYTES_PER_LINE = 16;
3
3
  const GROUP = 8;
4
4
  const GROUP_WIDTH = GROUP * 3 - 1;
5
5
  const NOT_HEX = /[^0-9a-f]/;
@@ -22,7 +22,6 @@ export const bytesOf = (hex) => {
22
22
  };
23
23
  /* Bytes that are not valid UTF-8 become replacement characters rather than an error. */
24
24
  export const decodeUtf8 = (hex) => new TextDecoder('utf-8').decode(bytesOf(hex));
25
- /* A UUID is exactly 16 bytes; anything else has no UUID form. */
26
25
  export const formatUuid = (hex) => {
27
26
  if (hex.length !== UUID_BYTES * 2) {
28
27
  return null;
@@ -1,4 +1,4 @@
1
- export type JsonCheck = {
1
+ type JsonCheck = {
2
2
  readonly ok: true;
3
3
  } | {
4
4
  readonly ok: false;
@@ -7,3 +7,4 @@ export type JsonCheck = {
7
7
  export declare const checkJson: (text: string) => JsonCheck;
8
8
  export declare const isJsonDocument: (text: string) => boolean;
9
9
  export declare const prettyJson: (text: string) => string | null;
10
+ export {};
@@ -14,7 +14,6 @@ export const isJsonDocument = (text) => {
14
14
  const start = text.trimStart()[0];
15
15
  return (start === '{' || start === '[') && checkJson(text).ok;
16
16
  };
17
- /* The text laid out with two spaces per level, or `null` when it is not JSON. */
18
17
  export const prettyJson = (text) => {
19
18
  if (!checkJson(text).ok) {
20
19
  return null;
@@ -5,7 +5,6 @@ export declare const sizeOf: (source: Source, draft: Draft) => {
5
5
  unit: 'bytes' | 'characters';
6
6
  count: number;
7
7
  } | null;
8
- export declare const DUMP_LIMIT_BYTES: number;
9
8
  export type Rendered = {
10
9
  readonly kind: 'empty';
11
10
  } | {
@@ -1,6 +1,5 @@
1
1
  import { decodeUtf8, formatUuid, hexDumpLines, parseHex } from './hex.js';
2
2
  import { checkJson, prettyJson } from './json.js';
3
- /* The views that make sense for this value, the first being the one it opens in. */
4
3
  export const viewsOf = (source, draft) => {
5
4
  if (source.binary) {
6
5
  const parsed = parseHex(draft.text);
@@ -9,7 +8,6 @@ export const viewsOf = (source, draft) => {
9
8
  }
10
9
  return source.json ? ['formatted', 'text'] : ['text'];
11
10
  };
12
- /* What a draft is, in bytes for a binary value and in characters for the rest; `null` when there is nothing to measure. */
13
11
  export const sizeOf = (source, draft) => {
14
12
  if (draft.mode !== 'value') {
15
13
  return null;
@@ -21,7 +19,7 @@ export const sizeOf = (source, draft) => {
21
19
  return parsed.ok ? { unit: 'bytes', count: parsed.hex.length / 2 } : null;
22
20
  };
23
21
  /* A read only view stops its dump here; the text view and a copy are not limited. */
24
- export const DUMP_LIMIT_BYTES = 16 * 1024;
22
+ const DUMP_LIMIT_BYTES = 16 * 1024;
25
23
  /* What a read only view shows for the draft. The text view is not here, since it is the editor itself. */
26
24
  export const renderView = (view, draft) => {
27
25
  if (draft.mode !== 'value') {
@@ -37,7 +37,6 @@ export function DatabaseWorkbench({ connections, onConnectionsChange, className,
37
37
  const [width, setWidth] = useState(DEFAULT_WIDTH);
38
38
  const [managing, setManaging] = useState(false);
39
39
  const [managed, setManaged] = useState(null);
40
- /* Ids of the table tabs that hold changes nobody submitted, and the tab a person asked to close while it does. */
41
40
  const [dirty, setDirty] = useState(() => new Set());
42
41
  const [closing, setClosing] = useState(null);
43
42
  const { startResize } = useColumnResize(column, { size: width, min: MIN_WIDTH, from: 'left', max: () => window.innerWidth / 2, onSize: setWidth });
@@ -113,7 +112,6 @@ export function DatabaseWorkbench({ connections, onConnectionsChange, className,
113
112
  function closeById(id) {
114
113
  setState((current) => closeTab(current, id));
115
114
  }
116
- /* A table tab with changes that are not submitted asks first. */
117
115
  function requestClose(id) {
118
116
  if (dirty.has(id)) {
119
117
  setClosing(id);
@@ -1,6 +1,6 @@
1
1
  import type { Connection } from '../client/types.ts';
2
2
  import type { WorkbenchTab } from './tabs.ts';
3
- export interface DesignerTabProps {
3
+ interface DesignerTabProps {
4
4
  connection: Connection;
5
5
  tab: Extract<WorkbenchTab, {
6
6
  kind: 'designer';
@@ -8,3 +8,4 @@ export interface DesignerTabProps {
8
8
  onTableChange(table: string): void;
9
9
  }
10
10
  export declare function DesignerTab({ connection, tab, onTableChange }: DesignerTabProps): import("react").JSX.Element;
11
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type { Connection } from '../client/types.ts';
2
2
  import type { WorkbenchTab } from './tabs.ts';
3
- export interface TableTabProps {
3
+ interface TableTabProps {
4
4
  connection: Connection;
5
5
  tab: Extract<WorkbenchTab, {
6
6
  kind: 'table';
@@ -8,3 +8,4 @@ export interface TableTabProps {
8
8
  onDirtyChange?(dirty: boolean): void;
9
9
  }
10
10
  export declare function TableTab({ connection, tab, onDirtyChange }: TableTabProps): import("react").JSX.Element;
11
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { TableRef } from '../client/types.ts';
2
- export type TableViewMode = 'data' | 'structure';
2
+ type TableViewMode = 'data' | 'structure';
3
3
  export type WorkbenchTab = {
4
4
  readonly id: string;
5
5
  readonly kind: 'table';
@@ -20,7 +20,7 @@ export type WorkbenchTab = {
20
20
  readonly schema: string;
21
21
  readonly table?: string;
22
22
  };
23
- export interface WorkbenchState {
23
+ interface WorkbenchState {
24
24
  readonly tabs: readonly WorkbenchTab[];
25
25
  readonly activeId: string | null;
26
26
  readonly serial: number;
@@ -40,3 +40,4 @@ export declare const closeTab: (state: WorkbenchState, id: string) => WorkbenchS
40
40
  export declare const pruneTabs: (state: WorkbenchState, connectionIds: ReadonlySet<string>) => WorkbenchState;
41
41
  export declare const serializeState: (state: WorkbenchState) => string;
42
42
  export declare const parseState: (raw: string | null) => WorkbenchState;
43
+ export {};
@@ -45,7 +45,6 @@ export const openDesigner = (state, connectionId, schema, table) => {
45
45
  };
46
46
  export const setTableView = (state, id, view) => update(state, id, (tab) => (tab.kind === 'table' && tab.view !== view ? { ...tab, view } : tab));
47
47
  export const setConsoleSql = (state, id, sql) => update(state, id, (tab) => (tab.kind === 'console' && tab.sql !== sql ? { ...tab, sql } : tab));
48
- /* The designer of a new table became the designer of that table, in the same tab. Closes any other designer of it. */
49
48
  export const setDesignerTable = (state, id, table) => {
50
49
  const subject = state.tabs.find((tab) => tab.id === id);
51
50
  if (subject?.kind !== 'designer' || subject.table === table) {
@@ -54,7 +53,6 @@ export const setDesignerTable = (state, id, table) => {
54
53
  const tabs = state.tabs.filter((tab) => tab.id === id || !isDesignerOf(tab, subject.connectionId, subject.schema, table));
55
54
  return update({ ...state, tabs }, id, (tab) => (tab.kind === 'designer' ? { ...tab, table } : tab));
56
55
  };
57
- /* The tab next to the closed one comes forward when the closed one was in front. */
58
56
  export const closeTab = (state, id) => {
59
57
  const at = state.tabs.findIndex((tab) => tab.id === id);
60
58
  if (at < 0) {
@@ -63,7 +61,6 @@ export const closeTab = (state, id) => {
63
61
  const tabs = state.tabs.filter((tab) => tab.id !== id);
64
62
  return { ...state, tabs, activeId: state.activeId === id ? (tabs[Math.min(at, tabs.length - 1)]?.id ?? null) : state.activeId };
65
63
  };
66
- /* Drops the tabs of connections that are gone. */
67
64
  export const pruneTabs = (state, connectionIds) => {
68
65
  const tabs = state.tabs.filter((tab) => connectionIds.has(connectionIdOf(tab)));
69
66
  if (tabs.length === state.tabs.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/database",
3
- "version": "0.62.1",
3
+ "version": "0.63.0",
4
4
  "description": "Browse, query and edit SQLite and MySQL databases: React views for the page, a host for the backend and a native helper that talks to the server.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "author": "Bas Milius",
@@ -50,33 +50,32 @@
50
50
  "build": "bun scripts/build.ts",
51
51
  "typecheck": "bun check --no-script",
52
52
  "test": "bun test",
53
- "test:dom": "bun test --preload ../ui/src/file-tree/testing/preload.ts interaction",
53
+ "test:dom": "bun test --preload ../../scripts/dom-preload.ts .dom.test.",
54
54
  "helper:build": "cargo build --release --locked --manifest-path helper/Cargo.toml",
55
55
  "helper:check": "cargo fmt --manifest-path helper/Cargo.toml --check && cargo clippy --locked --manifest-path helper/Cargo.toml --all-targets -- -D warnings",
56
56
  "helper:test": "cargo test --locked --manifest-path helper/Cargo.toml"
57
57
  },
58
58
  "dependencies": {
59
- "@adecore/utils": "0.62.1",
59
+ "@adecore/utils": "0.63.0",
60
60
  "@base-ui/react": "^1.9.0",
61
61
  "clsx": "^2.1.1",
62
62
  "lucide-react": "^1.65.0"
63
63
  },
64
64
  "optionalDependencies": {
65
- "@adecore/database-darwin-arm64": "0.62.1",
66
- "@adecore/database-linux-arm64": "0.62.1",
67
- "@adecore/database-linux-x64": "0.62.1",
68
- "@adecore/database-win32-x64": "0.62.1"
65
+ "@adecore/database-darwin-arm64": "0.63.0",
66
+ "@adecore/database-linux-arm64": "0.63.0",
67
+ "@adecore/database-linux-x64": "0.63.0",
68
+ "@adecore/database-win32-x64": "0.63.0"
69
69
  },
70
70
  "peerDependencies": {
71
- "@adecore/ui": "^0.62.1",
71
+ "@adecore/ui": "^0.63.0",
72
72
  "i18next": "^26.4.2",
73
73
  "react": "^19.3.0",
74
74
  "react-dom": "^19.3.0",
75
75
  "react-i18next": "^17.0.15"
76
76
  },
77
77
  "devDependencies": {
78
- "@adecore/ui": "0.62.1",
79
- "@happy-dom/global-registrator": "^21.0.4",
78
+ "@adecore/ui": "0.63.0",
80
79
  "@types/bun": "^1.4.4",
81
80
  "@types/node": "^26.6.6",
82
81
  "@types/react": "^19.3.0",
@@ -2,7 +2,7 @@ import { use, useMemo, type ReactNode } from 'react';
2
2
  import type { DatabaseAction, DatabaseFiles, DatabaseNotice, DatabaseStorage } from './actions.ts';
3
3
  import { DatabaseContext } from './client-context.ts';
4
4
  import type { DatabaseClient } from './client/types.ts';
5
- import type { NumberNotation } from './grid/display.ts';
5
+ import type { NumberNotation } from './number-notation.ts';
6
6
  import { useDatabaseResources } from './use-database-resources.ts';
7
7
 
8
8
  export interface DatabaseProviderProps {
@@ -148,12 +148,10 @@ export interface DatabaseClient {
148
148
  * changed gets a new one, and the old one closes.
149
149
  */
150
150
  session(connection: Connection, channel?: string): DatabaseSession;
151
- /* Closes every channel of the connection. */
152
151
  disconnect(connectionId: string): Promise<void>;
153
152
  dispose(): Promise<void>;
154
153
  }
155
154
 
156
- /* A request that failed, with the code of the protocol. */
157
155
  export class DatabaseRequestError extends Error {
158
156
  readonly code: DatabaseErrorCode;
159
157
  readonly sqlState: string | undefined;
@@ -1,9 +1,9 @@
1
1
  import { createContext, use } from 'react';
2
2
  import type { DatabaseAction, DatabaseFiles, DatabaseNotice, DatabaseStorage } from './actions.ts';
3
3
  import type { DatabaseClient } from './client/types.ts';
4
- import type { NumberNotation } from './grid/display.ts';
4
+ import type { NumberNotation } from './number-notation.ts';
5
5
 
6
- export interface DatabaseContextValue {
6
+ interface DatabaseContextValue {
7
7
  readonly client: DatabaseClient;
8
8
  readonly onAction: ((action: DatabaseAction) => void) | undefined;
9
9
  readonly onNotice: ((notice: DatabaseNotice) => void) | undefined;
@@ -3,7 +3,7 @@ import type { Ref } from 'react';
3
3
  import type { Engine } from '../protocol/index.ts';
4
4
  import { ENGINE_ICONS } from './engine-icons.ts';
5
5
 
6
- export interface EngineIconProps {
6
+ interface EngineIconProps {
7
7
  engine: Engine;
8
8
  /* 12, 14, 16 or 20. */
9
9
  size?: number;
@@ -5,11 +5,9 @@ import { DEFAULT_MYSQL_PORT, defaultConfig, withMode } from './connection-config
5
5
  /* A container a MySQL connection can point at: what `discover` found, minus a file engine, which no container serves. */
6
6
  export const isMysqlContainer = (container: DockerContainer): boolean => container.engine !== 'sqlite';
7
7
 
8
- /* The Compose `project/service` of a container, when it has both. */
9
8
  export const composeNameOf = (container: DockerContainer): string | null =>
10
9
  container.project !== null && container.service !== null ? `${container.project}/${container.service}` : null;
11
10
 
12
- /* What names a container to a person: its Compose name, else its own. */
13
11
  export const containerTitle = (container: DockerContainer): string => composeNameOf(container) ?? container.name;
14
12
 
15
13
  /* The port to connect to inside the container: MySQL's own when the container lists it or lists nothing, else the first it lists. */
@@ -19,7 +17,6 @@ export const containerPortOf = (container: DockerContainer): number => {
19
17
  return ports.length === 0 || ports.includes(DEFAULT_MYSQL_PORT) ? DEFAULT_MYSQL_PORT : ports[0]!;
20
18
  };
21
19
 
22
- /* The host port a container publishes a port on, or `null` when it does not. */
23
20
  export const publishedPortOf = (container: DockerContainer, port: number): number | null =>
24
21
  container.ports.find((entry) => entry.container === port)?.host ?? null;
25
22
 
@@ -5,7 +5,7 @@ import { DatabaseRequestError } from '../client/types.ts';
5
5
  import type { DockerContainer } from '../protocol/index.ts';
6
6
 
7
7
  /* `unsupported` is a machine without Docker, or one the app cannot ask. */
8
- export type DockerState =
8
+ type DockerState =
9
9
  | { readonly status: 'loading' }
10
10
  | { readonly status: 'ready'; readonly containers: readonly DockerContainer[] }
11
11
  | { readonly status: 'unsupported'; readonly message: string }
@@ -4,7 +4,7 @@ import type { Ref } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import type { DestructiveStatement } from './destructive.ts';
6
6
 
7
- export interface DestructiveDialogProps {
7
+ interface DestructiveDialogProps {
8
8
  /* The statements to warn about; the dialog is open while there are any. */
9
9
  statements: readonly DestructiveStatement[];
10
10
  onConfirm(): void;
@@ -6,7 +6,7 @@ import { useState, type Ref } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { searchHistory, type HistoryEntry } from './history.ts';
8
8
 
9
- export interface HistoryPanelProps {
9
+ interface HistoryPanelProps {
10
10
  entries: readonly HistoryEntry[];
11
11
  /* Clicking puts the SQL in the editor, and Mod+click or a double click runs it as well. */
12
12
  onPick(entry: HistoryEntry, run: boolean): void;
@@ -63,10 +63,8 @@ interface PageState {
63
63
  readonly before: readonly number[];
64
64
  }
65
65
 
66
- /* Rows in the first page of a result, and in every page after it. */
67
66
  const PAGE_SIZE = 500;
68
67
 
69
- /* Where the height of the results is kept, in pixels, for every console. */
70
68
  export const RESULTS_HEIGHT_KEY = 'database:console-results';
71
69
 
72
70
  /* The results and the editor never shrink below these; the results start at half the console. */
@@ -239,7 +237,6 @@ export function QueryConsole({
239
237
  onValueChange?.(next);
240
238
  };
241
239
 
242
- /* The SQL a run of the scope sends, or null when there is nothing to run. */
243
240
  const targetOf = (scope: QueryConsoleRunScope): string | null => {
244
241
  if (engine === undefined) {
245
242
  return null;
@@ -3,7 +3,7 @@ import type { Ref } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import type { SchemaInfo } from '../protocol/index.ts';
5
5
 
6
- export interface SchemaPickerProps {
6
+ interface SchemaPickerProps {
7
7
  schemas: readonly SchemaInfo[];
8
8
  /* `null` while the statements run in whatever the session has selected. */
9
9
  value: string | null;
@@ -27,7 +27,7 @@ export interface ResultPager {
27
27
  onNext(): void;
28
28
  }
29
29
 
30
- export interface StatementResultViewProps {
30
+ interface StatementResultViewProps {
31
31
  result: StatementResult;
32
32
  /* The rows before the first one shown, so a later page counts on from the page before it. */
33
33
  offset?: number;
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
5
5
 
6
6
  export type TransactionMode = 'auto' | 'manual';
7
7
 
8
- export interface TransactionControlsProps {
8
+ interface TransactionControlsProps {
9
9
  mode: TransactionMode;
10
10
  onModeChange(mode: TransactionMode): void;
11
11
  /* Whether a transaction is open on the session, whichever mode began it. */
@@ -11,7 +11,6 @@ export interface DestructiveStatement {
11
11
 
12
12
  interface Word {
13
13
  readonly word: string;
14
- /* How many parentheses are open at the word. */
15
14
  readonly depth: number;
16
15
  }
17
16
 
@@ -1,6 +1,5 @@
1
1
  const LABEL_LENGTH = 32;
2
2
 
3
- /* The tab of a statement: its SQL on one line, cut where it gets long. */
4
3
  export const statementLabel = (sql: string): string => {
5
4
  const line = sql.replace(/\s+/g, ' ').trim();
6
5
 
@@ -10,7 +10,7 @@ interface Loaded {
10
10
  readonly changed: boolean;
11
11
  }
12
12
 
13
- export interface ConsoleHistory {
13
+ interface ConsoleHistory {
14
14
  readonly entries: readonly HistoryEntry[];
15
15
  record(entry: HistoryEntry): void;
16
16
  clear(): void;
@@ -77,7 +77,6 @@ const rebuildSql = (dialect: Dialect, schema: string, original: TableDraft, draf
77
77
  return statements;
78
78
  };
79
79
 
80
- /* `ALTER TABLE` where SQLite has one, a rebuild of the table for every other change. */
81
80
  export const sqliteAlterSql = (dialect: Dialect, schema: string, original: TableDraft, draft: TableDraft, diff: TableDiff): string[] => {
82
81
  if (needsRebuild(dialect, original, diff)) {
83
82
  return rebuildSql(dialect, schema, original, draft, diff);
package/src/ddl/alter.ts CHANGED
@@ -18,7 +18,6 @@ const unchanged = (diff: TableDiff): boolean =>
18
18
  diff.droppedForeignKeys.length === 0 &&
19
19
  diff.addedForeignKeys.length === 0;
20
20
 
21
- /* The fewest statements that turn the table of `structure` into the draft; none when the draft changes nothing. */
22
21
  export const alterTableSql = (dialect: Dialect, schema: string, structure: TableStructure, draft: TableDraft): string[] => {
23
22
  const original = draftOf(structure);
24
23
  const diff = diffOf(dialect, original, draft);
package/src/ddl/column.ts CHANGED
@@ -19,12 +19,11 @@ export const defaultClause = (expression: string): string => {
19
19
  return text.startsWith('(') && text.endsWith(')') ? text : `(${text})`;
20
20
  };
21
21
 
22
- export interface ColumnSqlOptions {
22
+ interface ColumnSqlOptions {
23
23
  /* SQLite only: the column is the whole primary key, which an `AUTOINCREMENT` has to be declared on. */
24
24
  readonly inlinePrimaryKey?: boolean;
25
25
  }
26
26
 
27
- /* A column's definition without its name: `varchar(255) NOT NULL DEFAULT 'x'`. */
28
27
  export const columnSpecSql = (dialect: Dialect, column: ColumnDraft, { inlinePrimaryKey = false }: ColumnSqlOptions = {}): string => {
29
28
  const mysql = dialect.engine === 'mysql';
30
29
  const parts: string[] = [];
package/src/ddl/create.ts CHANGED
@@ -6,7 +6,6 @@ import type { TableOptions } from './parse.ts';
6
6
 
7
7
  const INDENT = ' ';
8
8
 
9
- /* `CONSTRAINT name FOREIGN KEY (...) REFERENCES t (...) ON UPDATE .. ON DELETE ..`, shared by a create and an `ADD`. */
10
9
  export const foreignKeySql = (dialect: Dialect, schema: string, foreignKey: ForeignKeyDraft): string => {
11
10
  const sqlite = dialect.engine === 'sqlite';
12
11
 
@@ -52,11 +51,10 @@ const sqliteOptionsSql = (options: TableOptions): string[] => [...(options.stric
52
51
  export const inlineIndexSql = (dialect: Dialect, index: IndexDraft): string =>
53
52
  [index.unique ? 'UNIQUE INDEX' : 'INDEX', ...(index.name === '' ? [] : [quote(dialect, index.name)]), `(${columnList(dialect, index.columns)})`].join(' ');
54
53
 
55
- /* `CREATE [UNIQUE] INDEX name ON table (columns)`. */
56
54
  export const createIndexSql = (dialect: Dialect, schema: string, table: string, index: Pick<IndexDraft, 'name' | 'columns' | 'unique'>): string =>
57
55
  `CREATE ${index.unique ? 'UNIQUE ' : ''}INDEX ${dialect.engine === 'sqlite' ? sqliteSchemaPrefix(dialect, schema) : ''}${quote(dialect, index.name)} ON ${tableName(dialect, dialect.engine === 'sqlite' ? '' : schema, table)} (${columnList(dialect, index.columns)})`;
58
56
 
59
- export interface CreateParts {
57
+ interface CreateParts {
60
58
  readonly table: string;
61
59
  /* SQLite creates its indexes after the table, where MySQL declares them inside it. */
62
60
  readonly indexes: readonly IndexDraft[];
@@ -43,7 +43,6 @@ export const quote = (dialect: Dialect, name: string): string => quoteIdentifier
43
43
  const schemaOf = (dialect: Dialect, schema: string): string | undefined =>
44
44
  schema === '' || (dialect.engine === 'sqlite' && schema === 'main') ? undefined : schema;
45
45
 
46
- /* A table with its schema in front, when the statement needs one. */
47
46
  export const tableName = (dialect: Dialect, schema: string, table: string): string =>
48
47
  qualifiedName({ engine: dialect.engine, table, schema: schemaOf(dialect, schema) });
49
48
 
package/src/ddl/diff.ts CHANGED
@@ -4,7 +4,7 @@ import type { Dialect } from './dialect.ts';
4
4
  import type { ColumnDraft, ForeignKeyDraft, IndexDraft, TableDraft } from './draft.ts';
5
5
  import type { TableOptions } from './parse.ts';
6
6
 
7
- export interface KeptColumn {
7
+ interface KeptColumn {
8
8
  readonly original: ColumnDraft;
9
9
  readonly column: ColumnDraft;
10
10
  readonly renamed: boolean;
@@ -15,14 +15,14 @@ export interface KeptColumn {
15
15
  readonly after: string | null;
16
16
  }
17
17
 
18
- export interface AddedColumn {
18
+ interface AddedColumn {
19
19
  readonly column: ColumnDraft;
20
20
  /* Whether a column that stays comes after it, so that it cannot simply go to the end. */
21
21
  readonly placed: boolean;
22
22
  readonly after: string | null;
23
23
  }
24
24
 
25
- export interface RenamedIndex {
25
+ interface RenamedIndex {
26
26
  readonly from: IndexDraft;
27
27
  readonly to: IndexDraft;
28
28
  }
@@ -42,7 +42,6 @@ export interface TableDiff {
42
42
  readonly optionsChanged: boolean;
43
43
  }
44
44
 
45
- /* The positions of a longest run that already is in order, whose columns can stay where they are. */
46
45
  const longestRun = (positions: readonly number[]): ReadonlySet<number> => {
47
46
  const length: number[] = [];
48
47
  const previous: number[] = [];
@@ -168,7 +167,6 @@ const foreignKeyChanges = (original: TableDraft, draft: TableDraft, project: Pro
168
167
  return { droppedForeignKeys, addedForeignKeys };
169
168
  };
170
169
 
171
- /* What a draft changes in the table it came from, told apart by the names items kept. */
172
170
  export const diffOf = (dialect: Dialect, original: TableDraft, draft: TableDraft): TableDiff => {
173
171
  const renames = new Map(draft.columns.filter((column) => column.originalName !== null).map((column) => [column.originalName!, column.name]));
174
172
 
@@ -184,6 +182,5 @@ export const diffOf = (dialect: Dialect, original: TableDraft, draft: TableDraft
184
182
  };
185
183
  };
186
184
 
187
- /* Whether applying the draft removes a column, and with it the data in it. */
188
185
  export const dropsColumns = (original: TableDraft, draft: TableDraft): boolean =>
189
186
  original.columns.some((column) => !draft.columns.some((kept) => kept.originalName === column.name));
package/src/ddl/draft.ts CHANGED
@@ -61,7 +61,6 @@ export interface TableDraft {
61
61
 
62
62
  let counter = 0;
63
63
 
64
- /* A key no other item of this page has. */
65
64
  export const nextKey = (): string => `new-${++counter}`;
66
65
 
67
66
  export const emptyColumn = (name = ''): ColumnDraft => ({
@@ -102,7 +101,6 @@ const foreignKeyDraftOf = (foreignKey: ForeignKeyInfo, at: number): ForeignKeyDr
102
101
  onDelete: foreignKey.onDelete
103
102
  });
104
103
 
105
- /* The draft that changes nothing: what a structure already says. */
106
104
  export const draftOf = (structure: TableStructure): TableDraft => {
107
105
  const clauses = generatedClausesOf(structure.ddl);
108
106
 
package/src/ddl/parse.ts CHANGED
@@ -56,7 +56,6 @@ export interface Definition {
56
56
  readonly tail: string;
57
57
  }
58
58
 
59
- /* Splits a `CREATE TABLE` into its definitions and its table options, or `null` when it holds no parenthesis. */
60
59
  export const definitionOf = (ddl: string | null): Definition | null => {
61
60
  if (ddl === null) {
62
61
  return null;
@@ -94,7 +93,6 @@ export const definitionOf = (ddl: string | null): Definition | null => {
94
93
  };
95
94
  };
96
95
 
97
- /* The name a definition starts with, unquoted. */
98
96
  const leadingName = (item: string): string | null => {
99
97
  const mark = item[0];
100
98
 
@@ -116,7 +114,6 @@ const leadingName = (item: string): string | null => {
116
114
  const AS_OPEN = /\b(?:GENERATED\s+ALWAYS\s+)?AS\s*\(/i;
117
115
  const AS_SUFFIX = /^\s*(?:VIRTUAL|STORED|PERSISTENT)\b/i;
118
116
 
119
- /* The `GENERATED ALWAYS AS (...) STORED` clause of a column definition, or `null` when it has none. */
120
117
  const generatedClauseOf = (item: string): string | null => {
121
118
  // A default or a comment may hold the words, so the strings are blanked before the search.
122
119
  const masked = item.replace(/'(?:[^']|'')*'/g, (text) => ' '.repeat(text.length));
@@ -146,7 +143,6 @@ const generatedClauseOf = (item: string): string | null => {
146
143
  return item.slice(start.index, end + (suffix?.[0].length ?? 0)).trim();
147
144
  };
148
145
 
149
- /* The generated clause of every generated column in a table's DDL, by column name. */
150
146
  export const generatedClausesOf = (ddl: string | null): ReadonlyMap<string, string> => {
151
147
  const clauses = new Map<string, string>();
152
148
 
@@ -11,7 +11,6 @@ import type { EditorProps } from './editor-props.ts';
11
11
  const TH = 'sticky top-0 z-10 h-7 bg-surface px-2 text-left text-xs font-medium whitespace-nowrap text-text-faint';
12
12
  const TD = 'border-t border-border-soft px-2 py-1 align-middle';
13
13
 
14
- /* The columns of the table as rows to edit: name, type, null, default, key, comment and where each one sits. */
15
14
  export function ColumnsEditor({ draft, dialect, disabled, onChange, className, ref }: EditorProps) {
16
15
  const { t } = useTranslation('database');
17
16
  const listId = useId();
@@ -96,7 +95,6 @@ interface ColumnRowProps extends Pick<EditorProps, 'draft' | 'disabled' | 'onCha
96
95
  column: ColumnDraft;
97
96
  at: number;
98
97
  mysql: boolean;
99
- /* The id of the datalist with the suggested types. */
100
98
  listId: string;
101
99
  }
102
100