@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
@@ -32,9 +32,7 @@ export interface DesignerViewProps {
32
32
  dialect: Dialect;
33
33
  schema: string;
34
34
  draft: TableDraft;
35
- /* The table does not exist yet. */
36
35
  isNew: boolean;
37
- /* The draft differs from what was loaded. */
38
36
  changed: boolean;
39
37
  /* The tables a foreign key can point at. */
40
38
  tables: readonly string[];
@@ -43,12 +41,10 @@ export interface DesignerViewProps {
43
41
  readOnlyReason: string | null;
44
42
  /* What the last Apply answered with, kept until the next one. */
45
43
  failure: string | null;
46
- /* The confirmation of the statements is open. */
47
44
  confirming: boolean;
48
45
  /* The columns of a table a foreign key may point at, or `null` while they load. */
49
46
  referenceColumns(table: string): readonly string[] | null;
50
47
  onChange(draft: TableDraft): void;
51
- /* Opens the confirmation. */
52
48
  onRequestApply(): void;
53
49
  onConfirm(): Promise<void>;
54
50
  onCancelConfirm(): void;
@@ -62,7 +58,6 @@ export interface DesignerViewProps {
62
58
 
63
59
  const APPLY_SHORTCUT = /* @__PURE__ */ shortcut('Mod+S');
64
60
 
65
- /* The designer with everything it needs handed in: the name, the four tabs, what Apply would run and the confirmation before it does. */
66
61
  export function DesignerView({
67
62
  dialect,
68
63
  schema,
@@ -7,7 +7,7 @@ import { addForeignKey, patchForeignKey, removeForeignKey, setReferencedTable, t
7
7
  import type { EditorProps } from './editor-props.ts';
8
8
  import { NamePicker } from './NamePicker.tsx';
9
9
 
10
- export interface ForeignKeysEditorProps extends EditorProps {
10
+ interface ForeignKeysEditorProps extends EditorProps {
11
11
  schema: string;
12
12
  /* The tables a key can point at. */
13
13
  tables: readonly string[];
@@ -4,13 +4,11 @@ import clsx from 'clsx';
4
4
  import type { Ref } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
 
7
- export interface NamePickerProps {
8
- /* Every name that can be picked, in the order to show them. */
7
+ interface NamePickerProps {
9
8
  options: readonly string[];
10
9
  /* The names picked, in the order they were picked. For a key that order is the order of its columns. */
11
10
  value: readonly string[];
12
11
  onToggle(name: string): void;
13
- /* The accessible name of the group. */
14
12
  label: string;
15
13
  disabled?: boolean;
16
14
  className?: string;
@@ -7,20 +7,18 @@ import { CODE_TEXT } from '../code-text.ts';
7
7
  import type { DraftProblem } from '../ddl/index.ts';
8
8
  import { scriptOf, type Plan } from './plan.ts';
9
9
 
10
- export interface SqlPreviewProps {
10
+ interface SqlPreviewProps {
11
11
  plan: Plan;
12
12
  className?: string;
13
13
  ref?: Ref<HTMLDivElement>;
14
14
  }
15
15
 
16
- /* The sentence a problem of the draft is read as. */
17
16
  function ProblemText({ problem }: { problem: DraftProblem }) {
18
17
  const { t } = useTranslation('database');
19
18
 
20
19
  return <>{t(`ddl.problem.${problem.code}`, { subject: problem.subject })}</>;
21
20
  }
22
21
 
23
- /* What Apply would run, as a person reads it: monospace, read only, and copyable. */
24
22
  export function SqlPreview({ plan, className, ref }: SqlPreviewProps) {
25
23
  const { t } = useTranslation('database');
26
24
  const script = scriptOf(plan.statements);
@@ -25,7 +25,6 @@ export interface TableDesignerProps {
25
25
  ref?: Ref<HTMLDivElement>;
26
26
  }
27
27
 
28
- /* What the designer starts from. */
29
28
  interface Snapshot {
30
29
  readonly dialect: Dialect;
31
30
  /* `null` for a table that does not exist yet. */
@@ -86,7 +85,6 @@ export function TableDesigner({ connection, schema, table, toolbarStart, classNa
86
85
  }
87
86
  });
88
87
 
89
- // A new snapshot, after a load or an apply, starts a fresh draft.
90
88
  if (snapshot !== null && editing.snapshot !== snapshot) {
91
89
  const baseline = snapshot.structure === null ? emptyDraft() : draftOf(snapshot.structure);
92
90
  setEditing({ snapshot, baseline, draft: baseline });
@@ -1,7 +1,5 @@
1
1
  import { emptyColumn, nextKey, type ColumnDraft, type ForeignKeyDraft, type IndexDraft, type TableDraft, type TableOptions } from '../ddl/index.ts';
2
2
 
3
- /* The editing steps of a draft. Each returns a new draft and leaves the one it was given alone. */
4
-
5
3
  const replaceAt = <T extends { readonly key: string }>(items: readonly T[], key: string, change: (item: T) => T): T[] =>
6
4
  items.map((item) => (item.key === key ? change(item) : item));
7
5
 
@@ -1,7 +1,6 @@
1
1
  import type { Ref } from 'react';
2
2
  import type { Dialect, TableDraft } from '../ddl/index.ts';
3
3
 
4
- /* What every tab of the designer is given: the draft it edits, and a way to hand back the next one. */
5
4
  export interface EditorProps {
6
5
  draft: TableDraft;
7
6
  dialect: Dialect;
@@ -1,7 +1,6 @@
1
1
  import { alterTableSql, createTableSql, dropsColumns, draftOf, validateDraft, type Dialect, type DraftProblem, type TableDraft } from '../ddl/index.ts';
2
2
  import type { TableStructure } from '../protocol/index.ts';
3
3
 
4
- /* What applying a draft would do. */
5
4
  export interface Plan {
6
5
  readonly problems: readonly DraftProblem[];
7
6
  /* Empty while there are problems, since a draft that does not hold together has no SQL. */
@@ -24,5 +23,4 @@ export const planOf = (dialect: Dialect, schema: string, structure: TableStructu
24
23
  return { problems, statements: alterTableSql(dialect, schema, structure, draft), destructive: dropsColumns(draftOf(structure), draft) };
25
24
  };
26
25
 
27
- /* The statements as a person reads them and as a script runs them. */
28
26
  export const scriptOf = (statements: readonly string[]): string => statements.map((statement) => `${statement};`).join('\n');
@@ -514,7 +514,6 @@ function ColumnIcon(keys: ColumnKeys) {
514
514
  );
515
515
  }
516
516
 
517
- /* A key, a foreign key, an index, a check or a trigger of a table: its name, and what it covers in the quiet color of a column's type. */
518
517
  function EntryContent({ row }: { row: EntryRow }) {
519
518
  const { t } = useTranslation('database');
520
519
  const { entry } = row;
@@ -23,7 +23,7 @@ import type { TableKind } from '../protocol/index.ts';
23
23
  import type { TableRequest } from './TableDialog.tsx';
24
24
  import { selectAllSql, type LoadTarget, type TreeRow } from './tree.ts';
25
25
 
26
- export interface RowMenuProps {
26
+ interface RowMenuProps {
27
27
  row: TreeRow;
28
28
  connection: Connection;
29
29
  onRefresh(target: LoadTarget): void;
@@ -13,7 +13,7 @@ export interface TableRequest {
13
13
  readonly kind: TableKind;
14
14
  }
15
15
 
16
- export interface TableDialogProps {
16
+ interface TableDialogProps {
17
17
  request: TableRequest;
18
18
  onClose(): void;
19
19
  /* After the statement ran; `to` is the new name of a rename. */
@@ -3,7 +3,6 @@ import { connectionOfKey, startsOpen } from './tree.ts';
3
3
  const VERSION = 1;
4
4
 
5
5
  export interface Expansion {
6
- /* Connections, schemas, tables and the folders of a table the person opened. */
7
6
  readonly expanded: ReadonlySet<string>;
8
7
  /* What starts open and the person closed: the folders of a schema and the columns of a table. */
9
8
  readonly collapsed: ReadonlySet<string>;
@@ -2,7 +2,6 @@ import type { TableRef } from '../client/types.ts';
2
2
  import { dropTableSql, dropViewSql, renameTableSql, truncateTableSql, type Dialect } from '../ddl/index.ts';
3
3
  import type { TableKind } from '../protocol/index.ts';
4
4
 
5
- /* What the explorer's menu changes about a table: its name, its rows, or its existence. */
6
5
  export type TableChange = 'rename' | 'truncate' | 'drop';
7
6
 
8
7
  /* The statement for a change; `to` is the new name of a rename. */
@@ -15,7 +15,6 @@ import type {
15
15
  import { qualifiedName } from '../sql.ts';
16
16
  import type { ExplorerFolder, ExplorerItem } from './folders.ts';
17
17
 
18
- /* Where a lazy list stands: not asked for yet, on its way, failed, or here. */
19
18
  export type Load<T> =
20
19
  | { readonly status: 'idle' }
21
20
  | { readonly status: 'loading' }
@@ -24,7 +23,6 @@ export type Load<T> =
24
23
 
25
24
  export const IDLE: Load<never> = { status: 'idle' };
26
25
 
27
- /* What a load fetches: the schemas of a connection, the tables of one schema, or the structure of one table. */
28
26
  export interface LoadTarget {
29
27
  readonly connectionId: string;
30
28
  readonly schema?: string;
@@ -42,8 +40,7 @@ export const folderKey = (connectionId: string, schema: string, group: TableKind
42
40
 
43
41
  export const tableKey = (ref: TableRef): string => `t:${ref.connectionId}${SEPARATOR}${ref.schema}${SEPARATOR}${ref.table}`;
44
42
 
45
- /* The folders of a table, in the order they come under it. */
46
- export const PARTS = ['columns', 'keys', 'foreignKeys', 'indexes', 'checks', 'triggers'] as const;
43
+ const PARTS = ['columns', 'keys', 'foreignKeys', 'indexes', 'checks', 'triggers'] as const;
47
44
 
48
45
  export type TablePart = (typeof PARTS)[number];
49
46
 
@@ -52,7 +49,6 @@ export const partKey = (ref: TableRef, part: TablePart): string => `p:${ref.conn
52
49
  /* A folder of a schema, and the columns of a table, are open until the person closes them; everything else is closed until they open it. */
53
50
  export const startsOpen = (key: string): boolean => key.startsWith('f:') || (key.startsWith('p:') && key.endsWith(`${SEPARATOR}columns`));
54
51
 
55
- /* The connection a key of a connection, schema, folder or table belongs to. */
56
52
  export const connectionOfKey = (key: string): string => {
57
53
  const rest = key.slice(2);
58
54
  const end = rest.indexOf(SEPARATOR);
@@ -62,7 +58,6 @@ export const connectionOfKey = (key: string): string => {
62
58
 
63
59
  export const columnKey = (ref: TableRef, column: string): string => `${tableKey(ref)}${SEPARATOR}${column}`;
64
60
 
65
- /* A folder of the app's own under a connection, and an item in it. */
66
61
  export const appFolderKey = (connectionId: string, folder: string): string => `x:${connectionId}${SEPARATOR}${folder}`;
67
62
 
68
63
  const appItemKey = (connectionId: string, folder: string, item: string): string => `${appFolderKey(connectionId, folder)}${SEPARATOR}${item}`;
@@ -79,7 +74,6 @@ export const loadKey = (target: LoadTarget): string => {
79
74
  : tableKey({ connectionId: target.connectionId, schema: target.schema, table: target.table });
80
75
  };
81
76
 
82
- /* The kinds of table a schema lists, in the order of its folders. */
83
77
  export const GROUPS: readonly TableKind[] = ['table', 'view'];
84
78
 
85
79
  interface RowBase {
@@ -93,7 +87,7 @@ interface RowBase {
93
87
  readonly focusable: boolean;
94
88
  }
95
89
 
96
- export interface ConnectionRow extends RowBase {
90
+ interface ConnectionRow extends RowBase {
97
91
  readonly kind: 'connection';
98
92
  readonly connection: Connection;
99
93
  readonly expanded: boolean;
@@ -103,7 +97,7 @@ export interface ConnectionRow extends RowBase {
103
97
  readonly schemaCount: { readonly shown: number; readonly total: number } | null;
104
98
  }
105
99
 
106
- export interface SchemaRow extends RowBase {
100
+ interface SchemaRow extends RowBase {
107
101
  readonly kind: 'schema';
108
102
  readonly connection: Connection;
109
103
  readonly schema: string;
@@ -111,7 +105,7 @@ export interface SchemaRow extends RowBase {
111
105
  }
112
106
 
113
107
  /* The "Tables" or the "Views" of a schema; it exists only when the schema has some. */
114
- export interface FolderRow extends RowBase {
108
+ interface FolderRow extends RowBase {
115
109
  readonly kind: 'folder';
116
110
  readonly connection: Connection;
117
111
  readonly schema: string;
@@ -138,7 +132,7 @@ export interface ColumnRow extends RowBase {
138
132
  }
139
133
 
140
134
  /* One of the folders a table opens into, which exists only when it holds something. */
141
- export interface PartRow extends RowBase {
135
+ interface PartRow extends RowBase {
142
136
  readonly kind: 'part';
143
137
  readonly ref: TableRef;
144
138
  readonly part: TablePart;
@@ -146,8 +140,7 @@ export interface PartRow extends RowBase {
146
140
  readonly count: number;
147
141
  }
148
142
 
149
- /* What a folder of a table holds besides its columns. */
150
- export type TableEntry =
143
+ type TableEntry =
151
144
  | { readonly type: 'key'; readonly name: string | null; readonly columns: readonly string[]; readonly primary: boolean }
152
145
  | { readonly type: 'foreignKey'; readonly foreignKey: ForeignKeyInfo }
153
146
  | { readonly type: 'index'; readonly index: IndexInfo }
@@ -160,7 +153,7 @@ export interface EntryRow extends RowBase {
160
153
  readonly entry: TableEntry;
161
154
  }
162
155
 
163
- export interface LoadingRow extends RowBase {
156
+ interface LoadingRow extends RowBase {
164
157
  readonly kind: 'loading';
165
158
  }
166
159
 
@@ -170,8 +163,7 @@ export interface ErrorRow extends RowBase {
170
163
  readonly retry: LoadTarget;
171
164
  }
172
165
 
173
- /* A folder of the app's own under a connection. */
174
- export interface AppFolderRow extends RowBase {
166
+ interface AppFolderRow extends RowBase {
175
167
  readonly kind: 'appFolder';
176
168
  readonly connection: Connection;
177
169
  readonly folder: ExplorerFolder;
@@ -180,14 +172,14 @@ export interface AppFolderRow extends RowBase {
180
172
  readonly count: number;
181
173
  }
182
174
 
183
- export interface AppItemRow extends RowBase {
175
+ interface AppItemRow extends RowBase {
184
176
  readonly kind: 'appItem';
185
177
  readonly connection: Connection;
186
178
  readonly item: ExplorerItem;
187
179
  }
188
180
 
189
181
  /* A connection without schemas, a schema without tables or a table without columns. */
190
- export interface EmptyRow extends RowBase {
182
+ interface EmptyRow extends RowBase {
191
183
  readonly kind: 'empty';
192
184
  readonly of: 'schemas' | 'tables' | 'columns';
193
185
  }
@@ -211,7 +203,6 @@ export type ExpandableRow = ConnectionRow | SchemaRow | FolderRow | TableRow | P
211
203
  export const isExpandable = (row: TreeRow): row is ExpandableRow =>
212
204
  row.kind === 'connection' || row.kind === 'schema' || row.kind === 'folder' || row.kind === 'table' || row.kind === 'part' || row.kind === 'appFolder';
213
205
 
214
- /* The table a row stands for, when it stands for one. */
215
206
  export const tableOf = (row: TreeRow): TableRef | null => (row.kind === 'table' || row.kind === 'column' || row.kind === 'entry' ? row.ref : null);
216
207
 
217
208
  /* The table activating a row opens: its own, or for a foreign key the table it references. */
@@ -245,7 +236,6 @@ export const selectionOf = (row: TreeRow): ExplorerSelection | null => {
245
236
  /* The key of the row a selection points at: its table, else its schema, else its connection. */
246
237
  export const selectionKey = (selection: ExplorerSelection): string => loadKey(selection);
247
238
 
248
- /* Whether a row has a menu: the rows of a connection, a schema, a table or a column, an item the app gave one, and none of the rows that only report. */
249
239
  export const hasMenu = (row: TreeRow): boolean =>
250
240
  row.kind === 'connection' ||
251
241
  row.kind === 'schema' ||
@@ -271,11 +261,10 @@ export interface TreeInput {
271
261
  tables(connectionId: string, schema: string): Load<readonly TableInfo[]>;
272
262
  structures(connectionId: string, schema: string, table: string): Load<TableStructure>;
273
263
  versions(connectionId: string): string | null;
274
- /* The app's own folders under a connection. */
275
264
  folders?(connectionId: string): readonly ExplorerFolder[];
276
265
  }
277
266
 
278
- export const visibleSchemas = (schemas: readonly SchemaInfo[], showSystemSchemas: boolean): readonly SchemaInfo[] =>
267
+ const visibleSchemas = (schemas: readonly SchemaInfo[], showSystemSchemas: boolean): readonly SchemaInfo[] =>
279
268
  showSystemSchemas ? schemas : schemas.filter((schema) => !schema.system);
280
269
 
281
270
  /* One schema is no level worth a row, so its folders hang straight under the connection. */
@@ -292,7 +281,6 @@ interface Draft {
292
281
  readonly below: readonly TreeRow[];
293
282
  }
294
283
 
295
- /* Gives the drafts of one parent their place among each other, and lays them out depth first. */
296
284
  const settle = (drafts: readonly Draft[]): TreeRow[] => drafts.flatMap((draft, i) => [draft.make({ posInSet: i + 1, setSize: drafts.length }), ...draft.below]);
297
285
 
298
286
  type StatusRow = { kind: 'loading' } | { kind: 'empty'; of: EmptyRow['of'] } | { kind: 'error'; message: string; retry: LoadTarget };
@@ -302,14 +290,12 @@ const statusDraft = (row: StatusRow, level: number, parent: string, focusable: b
302
290
  below: []
303
291
  });
304
292
 
305
- /* The row of a load that is not ready: its error, which can be retried and so takes the focus, or that it is loading. */
306
293
  const pendingDraft = (load: Exclude<Load<unknown>, { status: 'ready' }>, retry: LoadTarget, level: number, parent: string): Draft =>
307
294
  statusDraft(load.status === 'error' ? { kind: 'error', message: load.message, retry } : { kind: 'loading' }, level, parent, load.status === 'error');
308
295
 
309
296
  const matches = (name: string, query: string): boolean => name.toLowerCase().includes(query);
310
297
 
311
- /* What each folder of a table besides its columns holds: the primary key and the unique keys, the foreign keys, the other indexes, the checks and the triggers. */
312
- export const tableEntries = (structure: TableStructure): Readonly<Record<Exclude<TablePart, 'columns'>, readonly TableEntry[]>> => {
298
+ const tableEntries = (structure: TableStructure): Readonly<Record<Exclude<TablePart, 'columns'>, readonly TableEntry[]>> => {
313
299
  const primaryIndex = structure.indexes.find((index) => index.primary);
314
300
 
315
301
  const primary: TableEntry[] =
@@ -423,7 +409,6 @@ export const flattenTree = (input: TreeInput): TreeRow[] => {
423
409
  };
424
410
  };
425
411
 
426
- /* The folders under a schema (or under a connection with only that schema), and how many tables they hold. */
427
412
  const folderDrafts = (connection: Connection, schema: string, level: number, parent: string): { drafts: Draft[]; tables: number } => {
428
413
  const load = input.tables(connection.id, schema);
429
414
 
@@ -491,7 +476,6 @@ export const flattenTree = (input: TreeInput): TreeRow[] => {
491
476
  };
492
477
  };
493
478
 
494
- /* The app's folders under a connection, each while it holds items; with a filter only the items that match, in folders that count as open. */
495
479
  const appFolderDrafts = (connection: Connection, level: number, parent: string): Draft[] =>
496
480
  (input.folders?.(connection.id) ?? []).flatMap((folder): Draft[] => {
497
481
  const items = filtering ? folder.items.filter((item) => matches(item.label, query)) : folder.items;
@@ -581,7 +565,6 @@ export const flattenTree = (input: TreeInput): TreeRow[] => {
581
565
  return settle(input.connections.flatMap((connection) => connectionDraft(connection) ?? []));
582
566
  };
583
567
 
584
- /* The loads an open node is waiting for and nobody has asked for yet. */
585
568
  export const neededLoads = (input: Omit<TreeInput, 'filter'>): LoadTarget[] => {
586
569
  const needed: LoadTarget[] = [];
587
570
 
@@ -633,14 +616,13 @@ export const neededLoads = (input: Omit<TreeInput, 'filter'>): LoadTarget[] => {
633
616
  return needed;
634
617
  };
635
618
 
636
- export type TreeAction =
619
+ type TreeAction =
637
620
  | { readonly type: 'focus'; readonly key: string }
638
621
  | { readonly type: 'expand'; readonly key: string }
639
622
  | { readonly type: 'collapse'; readonly key: string }
640
623
  /* Enter or Space: opens a table (or the table of a column), toggles a node, retries a failed load. */
641
624
  | { readonly type: 'activate'; readonly key: string };
642
625
 
643
- /* What a key does to the row that has the focus, or `null` when it does nothing there. */
644
626
  export const navigate = (rows: readonly TreeRow[], activeKey: string | null, pressed: string): TreeAction | null => {
645
627
  const stops = rows.filter((row) => row.focusable);
646
628
 
@@ -14,13 +14,12 @@ interface Entry {
14
14
 
15
15
  interface Loads {
16
16
  readonly entries: ReadonlyMap<string, Entry>;
17
- /* The version each server reported, by connection. */
18
17
  readonly versions: ReadonlyMap<string, string>;
19
18
  }
20
19
 
21
20
  const EMPTY: Loads = { entries: new Map(), versions: new Map() };
22
21
 
23
- export interface ExplorerLoads {
22
+ interface ExplorerLoads {
24
23
  schemas(connectionId: string): Load<readonly SchemaInfo[]>;
25
24
  tables(connectionId: string, schema: string): Load<readonly TableInfo[]>;
26
25
  structures(connectionId: string, schema: string, table: string): Load<TableStructure>;
@@ -32,7 +31,6 @@ export interface ExplorerLoads {
32
31
  reset(target: LoadTarget): void;
33
32
  }
34
33
 
35
- /* Whether a load belongs to what a reset names: the same connection, and the same schema or table when the reset names one. */
36
34
  const within = (reset: LoadTarget, target: LoadTarget): boolean =>
37
35
  reset.connectionId === target.connectionId &&
38
36
  (reset.schema === undefined || reset.schema === target.schema) &&
@@ -42,7 +40,6 @@ const within = (reset: LoadTarget, target: LoadTarget): boolean =>
42
40
  const touches = (change: SchemaChange, target: LoadTarget): boolean =>
43
41
  change.connectionId === target.connectionId && (change.schema === undefined || target.schema === undefined || change.schema === target.schema);
44
42
 
45
- /* The schemas, tables and column lists the explorer has asked a session for, by connection, schema and table. */
46
43
  export function useExplorerLoads(connections: readonly Connection[]): ExplorerLoads {
47
44
  const client = useDatabaseClient();
48
45
  const [loads, setLoads] = useState<Loads>(EMPTY);
@@ -7,7 +7,6 @@ import { expansionKey, parseExpansion, serializeExpansion, type Expansion } from
7
7
  type Update = (current: ReadonlySet<string>) => ReadonlySet<string>;
8
8
 
9
9
  interface Loaded extends Expansion {
10
- /* The connections whose stored state is in the sets. */
11
10
  readonly loaded: ReadonlySet<string>;
12
11
  }
13
12
 
@@ -30,7 +29,7 @@ const restore = (storage: DatabaseStorage | undefined, connections: readonly Con
30
29
  return { expanded, collapsed, loaded };
31
30
  };
32
31
 
33
- export interface StoredExpansion extends Expansion {
32
+ interface StoredExpansion extends Expansion {
34
33
  setExpanded(update: Update): void;
35
34
  setCollapsed(update: Update): void;
36
35
  }
@@ -5,7 +5,7 @@ import { CODE_TEXT } from '../code-text.ts';
5
5
 
6
6
  export type EditMove = 'next' | 'previous';
7
7
 
8
- export interface CellEditorProps {
8
+ interface CellEditorProps {
9
9
  value: string;
10
10
  label: string;
11
11
  onValueChange(value: string): void;
@@ -14,7 +14,6 @@ export interface CellEditorProps {
14
14
  onCancel(): void;
15
15
  }
16
16
 
17
- /* The input a cell turns into while it is edited. It takes the focus and selects its text when it appears. */
18
17
  export function CellEditor({ value, label, onValueChange, onCommit, onCancel }: CellEditorProps) {
19
18
  const input = useRef<HTMLInputElement>(null);
20
19
 
@@ -5,7 +5,7 @@ import type { CopyFormat } from './copy-formats.ts';
5
5
 
6
6
  const ICONS: Record<CopyFormat, LucideIcon> = { tsv: Table2, csv: FileSpreadsheet, json: Braces, sql: Database };
7
7
 
8
- export interface CopyAsMenuProps {
8
+ interface CopyAsMenuProps {
9
9
  disabled: boolean;
10
10
  formats: readonly CopyFormat[];
11
11
  onCopy(format: CopyFormat): void;
@@ -19,6 +19,7 @@ import { useTranslation } from 'react-i18next';
19
19
  import type { DatabaseNotice } from '../actions.ts';
20
20
  import { assignRef } from '../assign-ref.ts';
21
21
  import { useNumberNotation } from '../client-context.ts';
22
+ import { type NumberNotation } from '../number-notation.ts';
22
23
  import type { EditValue, Value } from '../protocol/index.ts';
23
24
  import type { SqlTarget } from '../sql.ts';
24
25
  import { useDatabaseResources } from '../use-database-resources.ts';
@@ -33,7 +34,7 @@ import { NO_COLUMN_SELECTION, selectColumn, shownSelection, type ColumnSelection
33
34
  import { displayOrder, hideColumn, pinnedCount, showAllColumns, togglePin, type ColumnView } from './column-view.ts';
34
35
  import { COPY_FORMATS, formatCopy, type CopyFormat } from './copy-formats.ts';
35
36
  import { CopyAsMenu } from './CopyAsMenu.tsx';
36
- import { columnNotation, cellView, copyTextOf, isPreview, type CellView, type NumberNotation, type Shown } from './display.ts';
37
+ import { columnNotation, cellView, copyTextOf, isPreview, type CellView, type Shown } from './display.ts';
37
38
  import { draftOf, parseDraft } from './edit-value.ts';
38
39
  import { parseEnumType } from './enum-type.ts';
39
40
  import { GridHeaderCell, type HeaderActions } from './GridHeaderCell.tsx';
@@ -61,7 +62,6 @@ import { loadWholeCells } from './whole-cells.ts';
61
62
  export interface DataGridProps {
62
63
  columns: readonly GridColumn[];
63
64
  rows: readonly GridRow[];
64
- /* The accessible name of the grid. */
65
65
  label: string;
66
66
  /* Lets a cell be edited in place; the rows that are `locked` stay as they are. */
67
67
  editable?: boolean;
@@ -78,7 +78,6 @@ export interface DataGridProps {
78
78
  sorts?: readonly GridSort[];
79
79
  /* A header's menu picked a sort. The grid draws `rows` in the order given, so the handler orders them and passes `sorts` back. */
80
80
  onSortsChange?(sorts: readonly GridSort[]): void;
81
- /* The cell that holds the focus changed, or lost it. */
82
81
  onFocusedCellChange?(cell: FocusedCell | null): void;
83
82
  /* Delete or Backspace with rows selected. */
84
83
  onDeleteSelected?(): void;
@@ -514,7 +513,6 @@ export function DataGrid({
514
513
  }
515
514
  };
516
515
 
517
- /* The cells from row `top` to `bottom` in the given columns, with the whole value of every preview `loadValue` can fetch. */
518
516
  const wholeCellsOf = async (top: number, bottom: number, indexes: readonly number[]): Promise<readonly (readonly Shown[])[]> => {
519
517
  const shown = rows.slice(top, bottom + 1);
520
518
 
@@ -6,12 +6,11 @@ import { useTranslation } from 'react-i18next';
6
6
  import { CODE_TEXT } from '../code-text.ts';
7
7
  import { joinMembers, membersOf, type EnumType } from './enum-type.ts';
8
8
 
9
- export interface EnumPickerProps {
9
+ interface EnumPickerProps {
10
10
  type: EnumType;
11
11
  /* The column's value; `null` is NULL. A set is its members joined by commas. */
12
12
  value: string | null;
13
13
  nullable: boolean;
14
- /* The accessible name of the trigger. */
15
14
  label: string;
16
15
  /* Opens the menu as it mounts, for a cell that was just put into edit mode. */
17
16
  autoOpen?: boolean;
@@ -53,7 +53,6 @@ export interface GridHeaderCellProps {
53
53
 
54
54
  type MenuProps = Pick<GridHeaderCellProps, 'column' | 'index' | 'sortable' | 'hasSorts' | 'pinned' | 'hasHidden' | 'canHide' | 'actions'>;
55
55
 
56
- /* The items of the menu a header opens, from its button and from a right click. */
57
56
  function HeaderMenuItems({ column, index, sortable, hasSorts, pinned, hasHidden, canHide, actions }: MenuProps) {
58
57
  const { t } = useTranslation('database');
59
58
 
@@ -99,7 +98,6 @@ function HeaderMenuItems({ column, index, sortable, hasSorts, pinned, hasHidden,
99
98
  );
100
99
  }
101
100
 
102
- /* The facts about a table column that a tooltip can carry: its type, whether it takes NULL, its default. */
103
101
  function ColumnFacts({ column }: { column: GridColumn }) {
104
102
  const { t } = useTranslation('database');
105
103
  const keys = { primaryKey: column.primaryKey === true, foreignKey: column.foreignKey === true };
@@ -120,7 +118,6 @@ function ColumnFacts({ column }: { column: GridColumn }) {
120
118
  );
121
119
  }
122
120
 
123
- /* One column's head: its name, the sort it carries, the key of a key column, a menu and the strip that resizes it. Numbers sit against the end, like their cells. */
124
121
  export function GridHeaderCell({
125
122
  column,
126
123
  index,
@@ -3,9 +3,10 @@ import { formatNumber } from '@adecore/ui/format';
3
3
  import clsx from 'clsx';
4
4
  import { memo, type MouseEvent, type PointerEvent } from 'react';
5
5
  import { CODE_TEXT } from '../code-text.ts';
6
+ import { type NumberNotation } from '../number-notation.ts';
6
7
  import { cellIdOf } from './cell-id.ts';
7
8
  import { CellEditor, type EditMove } from './CellEditor.tsx';
8
- import { columnNotation, cellView, type CellView, type NumberNotation } from './display.ts';
9
+ import { columnNotation, cellView, type CellView } from './display.ts';
9
10
  import type { EnumType } from './enum-type.ts';
10
11
  import { EnumPicker } from './EnumPicker.tsx';
11
12
  import { ROW_HEIGHT } from './layout.ts';
@@ -48,7 +49,6 @@ export interface RowLook {
48
49
  readonly gutter: number;
49
50
  readonly notation: NumberNotation;
50
51
  readonly enumTypes: readonly (EnumType | null)[];
51
- /* Column indexes picked whole. */
52
52
  readonly picked: ReadonlySet<number>;
53
53
  readonly loadingLabel: string;
54
54
  }
@@ -66,7 +66,7 @@ export interface RowActions {
66
66
  changeDraft(draft: string): void;
67
67
  }
68
68
 
69
- export interface GridRowViewProps {
69
+ interface GridRowViewProps {
70
70
  row: GridRow;
71
71
  index: number;
72
72
  selected: boolean;
@@ -75,7 +75,6 @@ export interface GridRowViewProps {
75
75
  /* The drawn positions a cell range covers in this row, or -1 for both when it covers none. */
76
76
  rangeStart: number;
77
77
  rangeEnd: number;
78
- /* The edit under way when it is in this row. */
79
78
  editing: CellEdit | null;
80
79
  look: RowLook;
81
80
  actions: RowActions;
@@ -3,14 +3,12 @@ import clsx from 'clsx';
3
3
  import { useRef, useState, type ReactNode, type Ref } from 'react';
4
4
  import { assignRef } from '../assign-ref.ts';
5
5
 
6
- export const VALUE_PANEL_WIDTH = 320;
7
- export const VALUE_PANEL_MIN_WIDTH = 240;
6
+ const VALUE_PANEL_WIDTH = 320;
7
+ const VALUE_PANEL_MIN_WIDTH = 240;
8
8
 
9
- export interface ValueDockProps {
9
+ interface ValueDockProps {
10
10
  open: boolean;
11
- /* Drawn on the right of the children while the dock is open. */
12
11
  panel: ReactNode;
13
- /* The grid and whatever shares its column. */
14
12
  children: ReactNode;
15
13
  /* The width of the panel, when the owner keeps it; without it the dock keeps it itself. */
16
14
  width?: number;
@@ -19,7 +17,6 @@ export interface ValueDockProps {
19
17
  ref?: Ref<HTMLDivElement>;
20
18
  }
21
19
 
22
- /* A grid with a panel along its right edge that a person can widen by its left edge. */
23
20
  export function ValueDock({ open, panel, children, width: given, onWidthChange, className, ref }: ValueDockProps) {
24
21
  const root = useRef<HTMLDivElement | null>(null);
25
22
  const dock = useRef<HTMLDivElement>(null);
@@ -9,7 +9,7 @@ export interface RangeBlock {
9
9
  readonly columns: readonly number[];
10
10
  }
11
11
 
12
- export interface NumericAggregates {
12
+ interface NumericAggregates {
13
13
  /* The cells that held a number; NULLs and the cells of other columns do not count. */
14
14
  readonly count: number;
15
15
  readonly sum: number;
@@ -22,7 +22,6 @@ export interface NumericAggregates {
22
22
  }
23
23
 
24
24
  export interface Aggregates {
25
- /* Every cell of the block. */
26
25
  readonly count: number;
27
26
  /* `null` when no cell of the block held a number. */
28
27
  readonly numeric: NumericAggregates | null;