@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
package/README.md CHANGED
@@ -70,7 +70,7 @@ import { createDatabaseClient, DatabaseProvider, TableView } from '@adecore/data
70
70
  const client = createDatabaseClient((request) => window.database.request(request));
71
71
 
72
72
  createRoot(root).render(
73
- <UIProvider i18n={i18next} formatSource={formatSource}>
73
+ <UIProvider i18n={i18next}>
74
74
  <DatabaseProvider client={client}>
75
75
  <TableView connection={connection} schema="main" table="customers" className="h-full" />
76
76
  </DatabaseProvider>
@@ -1,7 +1,7 @@
1
1
  import { type ReactNode } 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
  export interface DatabaseProviderProps {
6
6
  client?: DatabaseClient;
7
7
  onAction?(action: DatabaseAction): void;
@@ -1,4 +1,3 @@
1
- /* A request that failed, with the code of the protocol. */
2
1
  export class DatabaseRequestError extends Error {
3
2
  code;
4
3
  sqlState;
@@ -1,7 +1,7 @@
1
1
  import type { DatabaseAction, DatabaseFiles, DatabaseNotice, DatabaseStorage } from './actions.ts';
2
2
  import type { DatabaseClient } from './client/types.ts';
3
- import type { NumberNotation } from './grid/display.ts';
4
- export interface DatabaseContextValue {
3
+ import type { NumberNotation } from './number-notation.ts';
4
+ interface DatabaseContextValue {
5
5
  readonly client: DatabaseClient;
6
6
  readonly onAction: ((action: DatabaseAction) => void) | undefined;
7
7
  readonly onNotice: ((notice: DatabaseNotice) => void) | undefined;
@@ -16,3 +16,4 @@ export declare const useDatabaseNotice: () => ((notice: DatabaseNotice) => void)
16
16
  export declare const useDatabaseStorage: () => DatabaseStorage | undefined;
17
17
  export declare const useDatabaseFiles: () => DatabaseFiles | undefined;
18
18
  export declare const useNumberNotation: () => NumberNotation;
19
+ export {};
@@ -1,9 +1,10 @@
1
1
  import type { Ref } from 'react';
2
2
  import type { Engine } from '../protocol/index.ts';
3
- export interface EngineIconProps {
3
+ interface EngineIconProps {
4
4
  engine: Engine;
5
5
  size?: number;
6
6
  className?: string;
7
7
  ref?: Ref<SVGSVGElement>;
8
8
  }
9
9
  export declare function EngineIcon({ engine, size, className, ref }: EngineIconProps): import("react").JSX.Element;
10
+ export {};
@@ -1,16 +1,13 @@
1
1
  import { DEFAULT_MYSQL_PORT, defaultConfig, withMode } from './connection-config.js';
2
2
  /* A container a MySQL connection can point at: what `discover` found, minus a file engine, which no container serves. */
3
3
  export const isMysqlContainer = (container) => container.engine !== 'sqlite';
4
- /* The Compose `project/service` of a container, when it has both. */
5
4
  export const composeNameOf = (container) => container.project !== null && container.service !== null ? `${container.project}/${container.service}` : null;
6
- /* What names a container to a person: its Compose name, else its own. */
7
5
  export const containerTitle = (container) => composeNameOf(container) ?? container.name;
8
6
  /* The port to connect to inside the container: MySQL's own when the container lists it or lists nothing, else the first it lists. */
9
7
  export const containerPortOf = (container) => {
10
8
  const ports = container.ports.map((entry) => entry.container);
11
9
  return ports.length === 0 || ports.includes(DEFAULT_MYSQL_PORT) ? DEFAULT_MYSQL_PORT : ports[0];
12
10
  };
13
- /* The host port a container publishes a port on, or `null` when it does not. */
14
11
  export const publishedPortOf = (container, port) => container.ports.find((entry) => entry.container === port)?.host ?? null;
15
12
  const isEmpty = (text) => text === undefined || text === '';
16
13
  /* Points a config at a container. The user, the password and the database come from the container's environment only where the config has none. */
@@ -1,5 +1,5 @@
1
1
  import type { DockerContainer } from '../protocol/index.ts';
2
- export type DockerState = {
2
+ type DockerState = {
3
3
  readonly status: 'loading';
4
4
  } | {
5
5
  readonly status: 'ready';
@@ -15,3 +15,4 @@ export declare function useDockerContainers(): {
15
15
  readonly state: DockerState;
16
16
  reload(): void;
17
17
  };
18
+ export {};
@@ -1,9 +1,10 @@
1
1
  import type { Ref } from 'react';
2
2
  import type { DestructiveStatement } from './destructive.ts';
3
- export interface DestructiveDialogProps {
3
+ interface DestructiveDialogProps {
4
4
  statements: readonly DestructiveStatement[];
5
5
  onConfirm(): void;
6
6
  onCancel(): void;
7
7
  ref?: Ref<HTMLDivElement>;
8
8
  }
9
9
  export declare function DestructiveDialog({ statements, onConfirm, onCancel, ref }: DestructiveDialogProps): import("react").JSX.Element;
10
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { type Ref } from 'react';
2
2
  import { type HistoryEntry } from './history.ts';
3
- export interface HistoryPanelProps {
3
+ interface HistoryPanelProps {
4
4
  entries: readonly HistoryEntry[];
5
5
  onPick(entry: HistoryEntry, run: boolean): void;
6
6
  onClear(): void;
@@ -8,3 +8,4 @@ export interface HistoryPanelProps {
8
8
  ref?: Ref<HTMLElement>;
9
9
  }
10
10
  export declare function HistoryPanel({ entries, onPick, onClear, className, ref }: HistoryPanelProps): import("react").JSX.Element;
11
+ export {};
@@ -22,9 +22,7 @@ import { SqlEditor } from './SqlEditor.js';
22
22
  import { StatementResultView } from './StatementResultView.js';
23
23
  import { TransactionControls } from './TransactionControls.js';
24
24
  import { useConsoleHistory } from './useConsoleHistory.js';
25
- /* Rows in the first page of a result, and in every page after it. */
26
25
  const PAGE_SIZE = 500;
27
- /* Where the height of the results is kept, in pixels, for every console. */
28
26
  export const RESULTS_HEIGHT_KEY = 'database:console-results';
29
27
  /* The results and the editor never shrink below these; the results start at half the console. */
30
28
  const MIN_RESULTS_HEIGHT = 96;
@@ -129,7 +127,6 @@ export function QueryConsole({ connection, schema, onSchemaChange, value, defaul
129
127
  }
130
128
  onValueChange?.(next);
131
129
  };
132
- /* The SQL a run of the scope sends, or null when there is nothing to run. */
133
130
  const targetOf = (scope) => {
134
131
  if (engine === undefined) {
135
132
  return null;
@@ -1,6 +1,6 @@
1
1
  import type { Ref } from 'react';
2
2
  import type { SchemaInfo } from '../protocol/index.ts';
3
- export interface SchemaPickerProps {
3
+ interface SchemaPickerProps {
4
4
  schemas: readonly SchemaInfo[];
5
5
  value: string | null;
6
6
  onValueChange(schema: string): void;
@@ -9,3 +9,4 @@ export interface SchemaPickerProps {
9
9
  ref?: Ref<HTMLButtonElement>;
10
10
  }
11
11
  export declare function SchemaPicker({ schemas, value, onValueChange, disabled, className, ref }: SchemaPickerProps): import("react").JSX.Element;
12
+ export {};
@@ -8,7 +8,7 @@ export interface ResultPager {
8
8
  onPrevious(): void;
9
9
  onNext(): void;
10
10
  }
11
- export interface StatementResultViewProps {
11
+ interface StatementResultViewProps {
12
12
  result: StatementResult;
13
13
  offset?: number;
14
14
  pager?: ResultPager;
@@ -22,3 +22,4 @@ export interface StatementResultViewProps {
22
22
  onNotice?(notice: DatabaseNotice): void;
23
23
  }
24
24
  export declare function StatementResultView({ result, offset, pager, onExport, exporting, engine, valuePanelOpen, onValuePanelOpenChange, keys, onFollowReference, onNotice }: StatementResultViewProps): import("react").JSX.Element;
25
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type { Ref } from 'react';
2
2
  export type TransactionMode = 'auto' | 'manual';
3
- export interface TransactionControlsProps {
3
+ interface TransactionControlsProps {
4
4
  mode: TransactionMode;
5
5
  onModeChange(mode: TransactionMode): void;
6
6
  open: boolean;
@@ -11,3 +11,4 @@ export interface TransactionControlsProps {
11
11
  ref?: Ref<HTMLDivElement>;
12
12
  }
13
13
  export declare function TransactionControls({ mode, onModeChange, open, busy, onCommit, onRollback, className, ref }: TransactionControlsProps): import("react").JSX.Element;
14
+ export {};
@@ -1,5 +1,4 @@
1
1
  const LABEL_LENGTH = 32;
2
- /* The tab of a statement: its SQL on one line, cut where it gets long. */
3
2
  export const statementLabel = (sql) => {
4
3
  const line = sql.replace(/\s+/g, ' ').trim();
5
4
  return line.length > LABEL_LENGTH ? `${line.slice(0, LABEL_LENGTH - 1).trimEnd()}…` : line;
@@ -1,7 +1,8 @@
1
1
  import { type HistoryEntry } from './history.ts';
2
- export interface ConsoleHistory {
2
+ interface ConsoleHistory {
3
3
  readonly entries: readonly HistoryEntry[];
4
4
  record(entry: HistoryEntry): void;
5
5
  clear(): void;
6
6
  }
7
7
  export declare function useConsoleHistory(connectionId: string): ConsoleHistory;
8
+ export {};
@@ -51,7 +51,6 @@ const rebuildSql = (dialect, schema, original, draft, diff) => {
51
51
  statements.push(`DROP TABLE ${tableName(dialect, schema, original.name)}`, `ALTER TABLE ${tableName(dialect, schema, temporary)} RENAME TO ${quote(dialect, draft.name)}`, ...indexes.map((index) => createIndexSql(dialect, schema, draft.name, index)), 'PRAGMA foreign_key_check', 'COMMIT', 'PRAGMA foreign_keys=ON');
52
52
  return statements;
53
53
  };
54
- /* `ALTER TABLE` where SQLite has one, a rebuild of the table for every other change. */
55
54
  export const sqliteAlterSql = (dialect, schema, original, draft, diff) => {
56
55
  if (needsRebuild(dialect, original, diff)) {
57
56
  return rebuildSql(dialect, schema, original, draft, diff);
package/dist/ddl/alter.js CHANGED
@@ -13,7 +13,6 @@ const unchanged = (diff) => !diff.renamed &&
13
13
  diff.renamedIndexes.length === 0 &&
14
14
  diff.droppedForeignKeys.length === 0 &&
15
15
  diff.addedForeignKeys.length === 0;
16
- /* The fewest statements that turn the table of `structure` into the draft; none when the draft changes nothing. */
17
16
  export const alterTableSql = (dialect, schema, structure, draft) => {
18
17
  const original = draftOf(structure);
19
18
  const diff = diffOf(dialect, original, draft);
@@ -1,9 +1,10 @@
1
1
  import { type Dialect } from './dialect.ts';
2
2
  import type { ColumnDraft } from './draft.ts';
3
3
  export declare const defaultClause: (expression: string) => string;
4
- export interface ColumnSqlOptions {
4
+ interface ColumnSqlOptions {
5
5
  readonly inlinePrimaryKey?: boolean;
6
6
  }
7
7
  export declare const columnSpecSql: (dialect: Dialect, column: ColumnDraft, { inlinePrimaryKey }?: ColumnSqlOptions) => string;
8
8
  export declare const columnSql: (dialect: Dialect, column: ColumnDraft, options?: ColumnSqlOptions) => string;
9
9
  export declare const sameDefinition: (dialect: Dialect, left: ColumnDraft, right: ColumnDraft) => boolean;
10
+ export {};
@@ -13,7 +13,6 @@ export const defaultClause = (expression) => {
13
13
  }
14
14
  return text.startsWith('(') && text.endsWith(')') ? text : `(${text})`;
15
15
  };
16
- /* A column's definition without its name: `varchar(255) NOT NULL DEFAULT 'x'`. */
17
16
  export const columnSpecSql = (dialect, column, { inlinePrimaryKey = false } = {}) => {
18
17
  const mysql = dialect.engine === 'mysql';
19
18
  const parts = [];
@@ -5,9 +5,10 @@ export declare const foreignKeySql: (dialect: Dialect, schema: string, foreignKe
5
5
  export declare const mysqlOptionsSql: (options: TableOptions, against?: TableOptions) => string[];
6
6
  export declare const inlineIndexSql: (dialect: Dialect, index: IndexDraft) => string;
7
7
  export declare const createIndexSql: (dialect: Dialect, schema: string, table: string, index: Pick<IndexDraft, 'name' | 'columns' | 'unique'>) => string;
8
- export interface CreateParts {
8
+ interface CreateParts {
9
9
  readonly table: string;
10
10
  readonly indexes: readonly IndexDraft[];
11
11
  }
12
12
  export declare const createTableParts: (dialect: Dialect, schema: string, draft: TableDraft, name: string) => CreateParts;
13
13
  export declare const createTableSql: (dialect: Dialect, schema: string, draft: TableDraft) => string[];
14
+ export {};
@@ -3,7 +3,6 @@ import { columnSql } from './column.js';
3
3
  import { columnList, quote, sqliteSchemaPrefix, tableName } from './dialect.js';
4
4
  import { isAutoIndex } from './draft.js';
5
5
  const INDENT = ' ';
6
- /* `CONSTRAINT name FOREIGN KEY (...) REFERENCES t (...) ON UPDATE .. ON DELETE ..`, shared by a create and an `ADD`. */
7
6
  export const foreignKeySql = (dialect, schema, foreignKey) => {
8
7
  const sqlite = dialect.engine === 'sqlite';
9
8
  // SQLite cannot name another schema in a reference, and MySQL needs one only for another database.
@@ -36,7 +35,6 @@ export const mysqlOptionsSql = (options, against) => {
36
35
  };
37
36
  const sqliteOptionsSql = (options) => [...(options.strict ? ['STRICT'] : []), ...(options.withoutRowid ? ['WITHOUT ROWID'] : [])];
38
37
  export const inlineIndexSql = (dialect, index) => [index.unique ? 'UNIQUE INDEX' : 'INDEX', ...(index.name === '' ? [] : [quote(dialect, index.name)]), `(${columnList(dialect, index.columns)})`].join(' ');
39
- /* `CREATE [UNIQUE] INDEX name ON table (columns)`. */
40
38
  export const createIndexSql = (dialect, schema, table, index) => `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)})`;
41
39
  /* The `CREATE TABLE` of a draft under a name of the caller's choosing, which a rebuild uses for the table it fills before the swap. */
42
40
  export const createTableParts = (dialect, schema, draft, name) => {
@@ -24,7 +24,6 @@ export const atLeast = (dialect, ...wanted) => {
24
24
  export const quote = (dialect, name) => quoteIdentifier(dialect.engine, name);
25
25
  /* SQLite reads an unqualified name as `main`, so only an attached schema is spelled out. */
26
26
  const schemaOf = (dialect, schema) => schema === '' || (dialect.engine === 'sqlite' && schema === 'main') ? undefined : schema;
27
- /* A table with its schema in front, when the statement needs one. */
28
27
  export const tableName = (dialect, schema, table) => qualifiedName({ engine: dialect.engine, table, schema: schemaOf(dialect, schema) });
29
28
  /* SQLite puts the schema in front of the name of an index, where MySQL names the table it is on. */
30
29
  export const sqliteSchemaPrefix = (dialect, schema) => {
@@ -1,6 +1,6 @@
1
1
  import type { Dialect } from './dialect.ts';
2
2
  import type { ColumnDraft, ForeignKeyDraft, IndexDraft, TableDraft } from './draft.ts';
3
- export interface KeptColumn {
3
+ interface KeptColumn {
4
4
  readonly original: ColumnDraft;
5
5
  readonly column: ColumnDraft;
6
6
  readonly renamed: boolean;
@@ -8,12 +8,12 @@ export interface KeptColumn {
8
8
  readonly moved: boolean;
9
9
  readonly after: string | null;
10
10
  }
11
- export interface AddedColumn {
11
+ interface AddedColumn {
12
12
  readonly column: ColumnDraft;
13
13
  readonly placed: boolean;
14
14
  readonly after: string | null;
15
15
  }
16
- export interface RenamedIndex {
16
+ interface RenamedIndex {
17
17
  readonly from: IndexDraft;
18
18
  readonly to: IndexDraft;
19
19
  }
@@ -32,3 +32,4 @@ export interface TableDiff {
32
32
  }
33
33
  export declare const diffOf: (dialect: Dialect, original: TableDraft, draft: TableDraft) => TableDiff;
34
34
  export declare const dropsColumns: (original: TableDraft, draft: TableDraft) => boolean;
35
+ export {};
package/dist/ddl/diff.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { sameList } from '../same-list.js';
2
2
  import { sameDefinition } from './column.js';
3
- /* The positions of a longest run that already is in order, whose columns can stay where they are. */
4
3
  const longestRun = (positions) => {
5
4
  const length = [];
6
5
  const previous = [];
@@ -96,7 +95,6 @@ const foreignKeyChanges = (original, draft, project) => {
96
95
  }
97
96
  return { droppedForeignKeys, addedForeignKeys };
98
97
  };
99
- /* What a draft changes in the table it came from, told apart by the names items kept. */
100
98
  export const diffOf = (dialect, original, draft) => {
101
99
  const renames = new Map(draft.columns.filter((column) => column.originalName !== null).map((column) => [column.originalName, column.name]));
102
100
  const project = (names) => names.map((name) => renames.get(name) ?? name);
@@ -109,5 +107,4 @@ export const diffOf = (dialect, original, draft) => {
109
107
  optionsChanged: OPTION_FIELDS.some((field) => original.options[field] !== draft.options[field])
110
108
  };
111
109
  };
112
- /* Whether applying the draft removes a column, and with it the data in it. */
113
110
  export const dropsColumns = (original, draft) => original.columns.some((column) => !draft.columns.some((kept) => kept.originalName === column.name));
package/dist/ddl/draft.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { generatedClausesOf, NO_OPTIONS, optionsOf } from './parse.js';
2
2
  let counter = 0;
3
- /* A key no other item of this page has. */
4
3
  export const nextKey = () => `new-${++counter}`;
5
4
  export const emptyColumn = (name = '') => ({
6
5
  key: nextKey(),
@@ -36,7 +35,6 @@ const foreignKeyDraftOf = (foreignKey, at) => ({
36
35
  onUpdate: foreignKey.onUpdate,
37
36
  onDelete: foreignKey.onDelete
38
37
  });
39
- /* The draft that changes nothing: what a structure already says. */
40
38
  export const draftOf = (structure) => {
41
39
  const clauses = generatedClausesOf(structure.ddl);
42
40
  return {
package/dist/ddl/parse.js CHANGED
@@ -32,7 +32,6 @@ function* unquoted(text, backslash) {
32
32
  }
33
33
  }
34
34
  }
35
- /* Splits a `CREATE TABLE` into its definitions and its table options, or `null` when it holds no parenthesis. */
36
35
  export const definitionOf = (ddl) => {
37
36
  if (ddl === null) {
38
37
  return null;
@@ -66,7 +65,6 @@ export const definitionOf = (ddl) => {
66
65
  tail: ddl.slice(close + 1)
67
66
  };
68
67
  };
69
- /* The name a definition starts with, unquoted. */
70
68
  const leadingName = (item) => {
71
69
  const mark = item[0];
72
70
  if (mark === '`' || mark === '"') {
@@ -81,7 +79,6 @@ const leadingName = (item) => {
81
79
  };
82
80
  const AS_OPEN = /\b(?:GENERATED\s+ALWAYS\s+)?AS\s*\(/i;
83
81
  const AS_SUFFIX = /^\s*(?:VIRTUAL|STORED|PERSISTENT)\b/i;
84
- /* The `GENERATED ALWAYS AS (...) STORED` clause of a column definition, or `null` when it has none. */
85
82
  const generatedClauseOf = (item) => {
86
83
  // A default or a comment may hold the words, so the strings are blanked before the search.
87
84
  const masked = item.replace(/'(?:[^']|'')*'/g, (text) => ' '.repeat(text.length));
@@ -103,7 +100,6 @@ const generatedClauseOf = (item) => {
103
100
  const suffix = AS_SUFFIX.exec(masked.slice(end));
104
101
  return item.slice(start.index, end + (suffix?.[0].length ?? 0)).trim();
105
102
  };
106
- /* The generated clause of every generated column in a table's DDL, by column name. */
107
103
  export const generatedClausesOf = (ddl) => {
108
104
  const clauses = new Map();
109
105
  for (const item of definitionOf(ddl)?.items ?? []) {
@@ -9,7 +9,6 @@ import { typeSuggestionsOf } from '../ddl/index.js';
9
9
  import { addColumn, moveColumn, patchColumn, removeColumn, togglePrimaryKey } from './edit.js';
10
10
  const TH = 'sticky top-0 z-10 h-7 bg-surface px-2 text-left text-xs font-medium whitespace-nowrap text-text-faint';
11
11
  const TD = 'border-t border-border-soft px-2 py-1 align-middle';
12
- /* The columns of the table as rows to edit: name, type, null, default, key, comment and where each one sits. */
13
12
  export function ColumnsEditor({ draft, dialect, disabled, onChange, className, ref }) {
14
13
  const { t } = useTranslation('database');
15
14
  const listId = useId();
@@ -13,7 +13,6 @@ import { OptionsEditor } from './OptionsEditor.js';
13
13
  import { scriptOf } from './plan.js';
14
14
  import { SqlPreview } from './SqlPreview.js';
15
15
  const APPLY_SHORTCUT = /* @__PURE__ */ shortcut('Mod+S');
16
- /* The designer with everything it needs handed in: the name, the four tabs, what Apply would run and the confirmation before it does. */
17
16
  export function DesignerView({ dialect, schema, draft, isNew, changed, tables, plan, readOnlyReason, failure, confirming, referenceColumns, onChange, onRequestApply, onConfirm, onCancelConfirm, onRevert, onDismissFailure, toolbarStart, className, ref }) {
18
17
  const { t } = useTranslation('database');
19
18
  const disabled = readOnlyReason !== null;
@@ -1,7 +1,8 @@
1
1
  import type { EditorProps } from './editor-props.ts';
2
- export interface ForeignKeysEditorProps extends EditorProps {
2
+ interface ForeignKeysEditorProps extends EditorProps {
3
3
  schema: string;
4
4
  tables: readonly string[];
5
5
  referenceColumns(table: string): readonly string[] | null;
6
6
  }
7
7
  export declare function ForeignKeysEditor({ draft, schema, tables, referenceColumns, disabled, onChange, className, ref }: ForeignKeysEditorProps): import("react").JSX.Element;
8
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { Ref } from 'react';
2
- export interface NamePickerProps {
2
+ interface NamePickerProps {
3
3
  options: readonly string[];
4
4
  value: readonly string[];
5
5
  onToggle(name: string): void;
@@ -9,3 +9,4 @@ export interface NamePickerProps {
9
9
  ref?: Ref<HTMLDivElement>;
10
10
  }
11
11
  export declare function NamePicker({ options, value, onToggle, label, disabled, className, ref }: NamePickerProps): import("react").JSX.Element;
12
+ export {};
@@ -1,8 +1,9 @@
1
1
  import type { Ref } from 'react';
2
2
  import { type Plan } from './plan.ts';
3
- export interface SqlPreviewProps {
3
+ interface SqlPreviewProps {
4
4
  plan: Plan;
5
5
  className?: string;
6
6
  ref?: Ref<HTMLDivElement>;
7
7
  }
8
8
  export declare function SqlPreview({ plan, className, ref }: SqlPreviewProps): import("react").JSX.Element;
9
+ export {};
@@ -5,12 +5,10 @@ import { Copy } from 'lucide-react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { CODE_TEXT } from '../code-text.js';
7
7
  import { scriptOf } from './plan.js';
8
- /* The sentence a problem of the draft is read as. */
9
8
  function ProblemText({ problem }) {
10
9
  const { t } = useTranslation('database');
11
10
  return _jsx(_Fragment, { children: t(`ddl.problem.${problem.code}`, { subject: problem.subject }) });
12
11
  }
13
- /* What Apply would run, as a person reads it: monospace, read only, and copyable. */
14
12
  export function SqlPreview({ plan, className, ref }) {
15
13
  const { t } = useTranslation('database');
16
14
  const script = scriptOf(plan.statements);
@@ -48,7 +48,6 @@ export function TableDesigner({ connection, schema, table, toolbarStart, classNa
48
48
  setShapeChanged(true);
49
49
  }
50
50
  });
51
- // A new snapshot, after a load or an apply, starts a fresh draft.
52
51
  if (snapshot !== null && editing.snapshot !== snapshot) {
53
52
  const baseline = snapshot.structure === null ? emptyDraft() : draftOf(snapshot.structure);
54
53
  setEditing({ snapshot, baseline, draft: baseline });
@@ -1,5 +1,4 @@
1
1
  import { emptyColumn, nextKey } from '../ddl/index.js';
2
- /* The editing steps of a draft. Each returns a new draft and leaves the one it was given alone. */
3
2
  const replaceAt = (items, key, change) => items.map((item) => (item.key === key ? change(item) : item));
4
3
  const toggled = (names, name) => names.includes(name) ? names.filter((candidate) => candidate !== name) : [...names, name];
5
4
  export const renameTable = (draft, name) => ({ ...draft, name });
@@ -9,5 +9,4 @@ export const planOf = (dialect, schema, structure, draft) => {
9
9
  }
10
10
  return { problems, statements: alterTableSql(dialect, schema, structure, draft), destructive: dropsColumns(draftOf(structure), draft) };
11
11
  };
12
- /* The statements as a person reads them and as a script runs them. */
13
12
  export const scriptOf = (statements) => statements.map((statement) => `${statement};`).join('\n');
@@ -278,7 +278,6 @@ function ColumnIcon(keys) {
278
278
  }
279
279
  return (_jsx(Tooltip, { label: t(keyLabelOf(keys)), children: _jsx("span", { className: ENTRY_ICON_SLOT, children: _jsx(KeyIcon, { ...keys, size: 14 }) }) }));
280
280
  }
281
- /* 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. */
282
281
  function EntryContent({ row }) {
283
282
  const { t } = useTranslation('database');
284
283
  const { entry } = row;
@@ -1,7 +1,7 @@
1
1
  import type { Connection } from '../client/types.ts';
2
2
  import type { TableRequest } from './TableDialog.tsx';
3
3
  import { type LoadTarget, type TreeRow } from './tree.ts';
4
- export interface RowMenuProps {
4
+ interface RowMenuProps {
5
5
  row: TreeRow;
6
6
  connection: Connection;
7
7
  onRefresh(target: LoadTarget): void;
@@ -9,3 +9,4 @@ export interface RowMenuProps {
9
9
  onRequest(request: TableRequest): void;
10
10
  }
11
11
  export declare function RowMenu({ row, connection, onRefresh, onDisconnect, onRequest }: RowMenuProps): import("react").JSX.Element[];
12
+ export {};
@@ -7,9 +7,10 @@ export interface TableRequest {
7
7
  readonly ref: TableRef;
8
8
  readonly kind: TableKind;
9
9
  }
10
- export interface TableDialogProps {
10
+ interface TableDialogProps {
11
11
  request: TableRequest;
12
12
  onClose(): void;
13
13
  onDone(request: TableRequest, to: string | undefined): void;
14
14
  }
15
15
  export declare function TableDialog({ request, onClose, onDone }: TableDialogProps): import("react").JSX.Element;
16
+ export {};
@@ -23,7 +23,7 @@ export declare const connectionKey: (connectionId: string) => string;
23
23
  export declare const schemaKey: (connectionId: string, schema: string) => string;
24
24
  export declare const folderKey: (connectionId: string, schema: string, group: TableKind) => string;
25
25
  export declare const tableKey: (ref: TableRef) => string;
26
- export declare const PARTS: readonly ['columns', 'keys', 'foreignKeys', 'indexes', 'checks', 'triggers'];
26
+ declare const PARTS: readonly ['columns', 'keys', 'foreignKeys', 'indexes', 'checks', 'triggers'];
27
27
  export type TablePart = (typeof PARTS)[number];
28
28
  export declare const partKey: (ref: TableRef, part: TablePart) => string;
29
29
  export declare const startsOpen: (key: string) => boolean;
@@ -40,7 +40,7 @@ interface RowBase {
40
40
  readonly setSize: number;
41
41
  readonly focusable: boolean;
42
42
  }
43
- export interface ConnectionRow extends RowBase {
43
+ interface ConnectionRow extends RowBase {
44
44
  readonly kind: 'connection';
45
45
  readonly connection: Connection;
46
46
  readonly expanded: boolean;
@@ -50,13 +50,13 @@ export interface ConnectionRow extends RowBase {
50
50
  readonly total: number;
51
51
  } | null;
52
52
  }
53
- export interface SchemaRow extends RowBase {
53
+ interface SchemaRow extends RowBase {
54
54
  readonly kind: 'schema';
55
55
  readonly connection: Connection;
56
56
  readonly schema: string;
57
57
  readonly expanded: boolean;
58
58
  }
59
- export interface FolderRow extends RowBase {
59
+ interface FolderRow extends RowBase {
60
60
  readonly kind: 'folder';
61
61
  readonly connection: Connection;
62
62
  readonly schema: string;
@@ -77,14 +77,14 @@ export interface ColumnRow extends RowBase {
77
77
  readonly primaryKey: boolean;
78
78
  readonly foreignKey: boolean;
79
79
  }
80
- export interface PartRow extends RowBase {
80
+ interface PartRow extends RowBase {
81
81
  readonly kind: 'part';
82
82
  readonly ref: TableRef;
83
83
  readonly part: TablePart;
84
84
  readonly expanded: boolean;
85
85
  readonly count: number;
86
86
  }
87
- export type TableEntry = {
87
+ type TableEntry = {
88
88
  readonly type: 'key';
89
89
  readonly name: string | null;
90
90
  readonly columns: readonly string[];
@@ -107,7 +107,7 @@ export interface EntryRow extends RowBase {
107
107
  readonly ref: TableRef;
108
108
  readonly entry: TableEntry;
109
109
  }
110
- export interface LoadingRow extends RowBase {
110
+ interface LoadingRow extends RowBase {
111
111
  readonly kind: 'loading';
112
112
  }
113
113
  export interface ErrorRow extends RowBase {
@@ -115,19 +115,19 @@ export interface ErrorRow extends RowBase {
115
115
  readonly message: string;
116
116
  readonly retry: LoadTarget;
117
117
  }
118
- export interface AppFolderRow extends RowBase {
118
+ interface AppFolderRow extends RowBase {
119
119
  readonly kind: 'appFolder';
120
120
  readonly connection: Connection;
121
121
  readonly folder: ExplorerFolder;
122
122
  readonly expanded: boolean;
123
123
  readonly count: number;
124
124
  }
125
- export interface AppItemRow extends RowBase {
125
+ interface AppItemRow extends RowBase {
126
126
  readonly kind: 'appItem';
127
127
  readonly connection: Connection;
128
128
  readonly item: ExplorerItem;
129
129
  }
130
- export interface EmptyRow extends RowBase {
130
+ interface EmptyRow extends RowBase {
131
131
  readonly kind: 'empty';
132
132
  readonly of: 'schemas' | 'tables' | 'columns';
133
133
  }
@@ -154,11 +154,9 @@ export interface TreeInput {
154
154
  versions(connectionId: string): string | null;
155
155
  folders?(connectionId: string): readonly ExplorerFolder[];
156
156
  }
157
- export declare const visibleSchemas: (schemas: readonly SchemaInfo[], showSystemSchemas: boolean) => readonly SchemaInfo[];
158
- export declare const tableEntries: (structure: TableStructure) => Readonly<Record<Exclude<TablePart, 'columns'>, readonly TableEntry[]>>;
159
157
  export declare const flattenTree: (input: TreeInput) => TreeRow[];
160
158
  export declare const neededLoads: (input: Omit<TreeInput, 'filter'>) => LoadTarget[];
161
- export type TreeAction = {
159
+ type TreeAction = {
162
160
  readonly type: 'focus';
163
161
  readonly key: string;
164
162
  } | {