@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
@@ -5,19 +5,16 @@ export const connectionKey = (connectionId) => `c:${connectionId}`;
5
5
  export const schemaKey = (connectionId, schema) => `s:${connectionId}${SEPARATOR}${schema}`;
6
6
  export const folderKey = (connectionId, schema, group) => `f:${connectionId}${SEPARATOR}${schema}${SEPARATOR}${group}`;
7
7
  export const tableKey = (ref) => `t:${ref.connectionId}${SEPARATOR}${ref.schema}${SEPARATOR}${ref.table}`;
8
- /* The folders of a table, in the order they come under it. */
9
- export const PARTS = ['columns', 'keys', 'foreignKeys', 'indexes', 'checks', 'triggers'];
8
+ const PARTS = ['columns', 'keys', 'foreignKeys', 'indexes', 'checks', 'triggers'];
10
9
  export const partKey = (ref, part) => `p:${ref.connectionId}${SEPARATOR}${ref.schema}${SEPARATOR}${ref.table}${SEPARATOR}${part}`;
11
10
  /* 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. */
12
11
  export const startsOpen = (key) => key.startsWith('f:') || (key.startsWith('p:') && key.endsWith(`${SEPARATOR}columns`));
13
- /* The connection a key of a connection, schema, folder or table belongs to. */
14
12
  export const connectionOfKey = (key) => {
15
13
  const rest = key.slice(2);
16
14
  const end = rest.indexOf(SEPARATOR);
17
15
  return end === -1 ? rest : rest.slice(0, end);
18
16
  };
19
17
  export const columnKey = (ref, column) => `${tableKey(ref)}${SEPARATOR}${column}`;
20
- /* A folder of the app's own under a connection, and an item in it. */
21
18
  export const appFolderKey = (connectionId, folder) => `x:${connectionId}${SEPARATOR}${folder}`;
22
19
  const appItemKey = (connectionId, folder, item) => `${appFolderKey(connectionId, folder)}${SEPARATOR}${item}`;
23
20
  const entryKey = (ref, part, index) => `${partKey(ref, part)}${SEPARATOR}${index}`;
@@ -29,10 +26,8 @@ export const loadKey = (target) => {
29
26
  ? schemaKey(target.connectionId, target.schema)
30
27
  : tableKey({ connectionId: target.connectionId, schema: target.schema, table: target.table });
31
28
  };
32
- /* The kinds of table a schema lists, in the order of its folders. */
33
29
  export const GROUPS = ['table', 'view'];
34
30
  export const isExpandable = (row) => row.kind === 'connection' || row.kind === 'schema' || row.kind === 'folder' || row.kind === 'table' || row.kind === 'part' || row.kind === 'appFolder';
35
- /* The table a row stands for, when it stands for one. */
36
31
  export const tableOf = (row) => (row.kind === 'table' || row.kind === 'column' || row.kind === 'entry' ? row.ref : null);
37
32
  /* The table activating a row opens: its own, or for a foreign key the table it references. */
38
33
  export const openedTableOf = (row) => row.kind === 'entry' && row.entry.type === 'foreignKey'
@@ -59,7 +54,6 @@ export const selectionOf = (row) => {
59
54
  };
60
55
  /* The key of the row a selection points at: its table, else its schema, else its connection. */
61
56
  export const selectionKey = (selection) => loadKey(selection);
62
- /* 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. */
63
57
  export const hasMenu = (row) => row.kind === 'connection' ||
64
58
  row.kind === 'schema' ||
65
59
  row.kind === 'folder' ||
@@ -70,20 +64,17 @@ export const hasMenu = (row) => row.kind === 'connection' ||
70
64
  export const isSelectable = (row) => row.kind === 'connection' || row.kind === 'schema' || row.kind === 'table';
71
65
  /* The statement behind New console here on a table: every row, as the engine quotes it. */
72
66
  export const selectAllSql = (engine, ref) => `SELECT * FROM ${qualifiedName({ engine, schema: ref.schema, table: ref.table })}`;
73
- export const visibleSchemas = (schemas, showSystemSchemas) => showSystemSchemas ? schemas : schemas.filter((schema) => !schema.system);
67
+ const visibleSchemas = (schemas, showSystemSchemas) => showSystemSchemas ? schemas : schemas.filter((schema) => !schema.system);
74
68
  /* One schema is no level worth a row, so its folders hang straight under the connection. */
75
69
  const soleSchema = (visible) => (visible.length === 1 ? visible[0].name : null);
76
- /* Gives the drafts of one parent their place among each other, and lays them out depth first. */
77
70
  const settle = (drafts) => drafts.flatMap((draft, i) => [draft.make({ posInSet: i + 1, setSize: drafts.length }), ...draft.below]);
78
71
  const statusDraft = (row, level, parent, focusable) => ({
79
72
  make: (place) => ({ ...row, key: `${row.kind}:${parent}`, level, parent, focusable, ...place }),
80
73
  below: []
81
74
  });
82
- /* 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. */
83
75
  const pendingDraft = (load, retry, level, parent) => statusDraft(load.status === 'error' ? { kind: 'error', message: load.message, retry } : { kind: 'loading' }, level, parent, load.status === 'error');
84
76
  const matches = (name, query) => name.toLowerCase().includes(query);
85
- /* 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. */
86
- export const tableEntries = (structure) => {
77
+ const tableEntries = (structure) => {
87
78
  const primaryIndex = structure.indexes.find((index) => index.primary);
88
79
  const primary = structure.primaryKey.length === 0 ? [] : [{ type: 'key', name: primaryIndex?.name ?? null, columns: structure.primaryKey, primary: true }];
89
80
  const unique = structure.indexes
@@ -175,7 +166,6 @@ export const flattenTree = (input) => {
175
166
  below: open ? settle(tableChildren(ref, table.kind, level + 1, key)) : []
176
167
  };
177
168
  };
178
- /* The folders under a schema (or under a connection with only that schema), and how many tables they hold. */
179
169
  const folderDrafts = (connection, schema, level, parent) => {
180
170
  const load = input.tables(connection.id, schema);
181
171
  if (load.status === 'ready') {
@@ -229,7 +219,6 @@ export const flattenTree = (input) => {
229
219
  below: open ? settle(drafts) : []
230
220
  };
231
221
  };
232
- /* 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. */
233
222
  const appFolderDrafts = (connection, level, parent) => (input.folders?.(connection.id) ?? []).flatMap((folder) => {
234
223
  const items = filtering ? folder.items.filter((item) => matches(item.label, query)) : folder.items;
235
224
  if (items.length === 0) {
@@ -307,7 +296,6 @@ export const flattenTree = (input) => {
307
296
  };
308
297
  return settle(input.connections.flatMap((connection) => connectionDraft(connection) ?? []));
309
298
  };
310
- /* The loads an open node is waiting for and nobody has asked for yet. */
311
299
  export const neededLoads = (input) => {
312
300
  const needed = [];
313
301
  for (const connection of input.connections) {
@@ -344,7 +332,6 @@ export const neededLoads = (input) => {
344
332
  }
345
333
  return needed;
346
334
  };
347
- /* What a key does to the row that has the focus, or `null` when it does nothing there. */
348
335
  export const navigate = (rows, activeKey, pressed) => {
349
336
  const stops = rows.filter((row) => row.focusable);
350
337
  if (stops.length === 0) {
@@ -1,7 +1,7 @@
1
1
  import type { Connection } from '../client/types.ts';
2
2
  import type { SchemaInfo, TableInfo, TableStructure } from '../protocol/index.ts';
3
3
  import { type Load, type LoadTarget } from './tree.ts';
4
- export interface ExplorerLoads {
4
+ interface ExplorerLoads {
5
5
  schemas(connectionId: string): Load<readonly SchemaInfo[]>;
6
6
  tables(connectionId: string, schema: string): Load<readonly TableInfo[]>;
7
7
  structures(connectionId: string, schema: string, table: string): Load<TableStructure>;
@@ -10,3 +10,4 @@ export interface ExplorerLoads {
10
10
  reset(target: LoadTarget): void;
11
11
  }
12
12
  export declare function useExplorerLoads(connections: readonly Connection[]): ExplorerLoads;
13
+ export {};
@@ -3,13 +3,11 @@ import { useEffect, useRef, useState } from 'react';
3
3
  import { useDatabaseClient } from '../client-context.js';
4
4
  import { IDLE, loadKey } from './tree.js';
5
5
  const EMPTY = { entries: new Map(), versions: new Map() };
6
- /* Whether a load belongs to what a reset names: the same connection, and the same schema or table when the reset names one. */
7
6
  const within = (reset, target) => reset.connectionId === target.connectionId &&
8
7
  (reset.schema === undefined || reset.schema === target.schema) &&
9
8
  (reset.table === undefined || reset.table === target.table);
10
9
  /* A change to a schema also changes the schema list, and one without a schema changes every list of the connection. */
11
10
  const touches = (change, target) => change.connectionId === target.connectionId && (change.schema === undefined || target.schema === undefined || change.schema === target.schema);
12
- /* The schemas, tables and column lists the explorer has asked a session for, by connection, schema and table. */
13
11
  export function useExplorerLoads(connections) {
14
12
  const client = useDatabaseClient();
15
13
  const [loads, setLoads] = useState(EMPTY);
@@ -1,7 +1,7 @@
1
1
  import type { Connection } from '../client/types.ts';
2
2
  import { type Expansion } from './expansion.ts';
3
3
  type Update = (current: ReadonlySet<string>) => ReadonlySet<string>;
4
- export interface StoredExpansion extends Expansion {
4
+ interface StoredExpansion extends Expansion {
5
5
  setExpanded(update: Update): void;
6
6
  setCollapsed(update: Update): void;
7
7
  }
@@ -1,5 +1,5 @@
1
1
  export type EditMove = 'next' | 'previous';
2
- export interface CellEditorProps {
2
+ interface CellEditorProps {
3
3
  value: string;
4
4
  label: string;
5
5
  onValueChange(value: string): void;
@@ -7,3 +7,4 @@ export interface CellEditorProps {
7
7
  onCancel(): void;
8
8
  }
9
9
  export declare function CellEditor({ value, label, onValueChange, onCommit, onCancel }: CellEditorProps): import("react").JSX.Element;
10
+ export {};
@@ -3,7 +3,6 @@ import { Input } from '@adecore/ui';
3
3
  import clsx from 'clsx';
4
4
  import { useEffect, useRef } from 'react';
5
5
  import { CODE_TEXT } from '../code-text.js';
6
- /* The input a cell turns into while it is edited. It takes the focus and selects its text when it appears. */
7
6
  export function CellEditor({ value, label, onValueChange, onCommit, onCancel }) {
8
7
  const input = useRef(null);
9
8
  useEffect(() => {
@@ -1,7 +1,8 @@
1
1
  import type { CopyFormat } from './copy-formats.ts';
2
- export interface CopyAsMenuProps {
2
+ interface CopyAsMenuProps {
3
3
  disabled: boolean;
4
4
  formats: readonly CopyFormat[];
5
5
  onCopy(format: CopyFormat): void;
6
6
  }
7
7
  export declare function CopyAsMenu({ disabled, formats, onCopy }: CopyAsMenuProps): import("react").JSX.Element;
8
+ export {};
@@ -7,6 +7,7 @@ import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { assignRef } from '../assign-ref.js';
9
9
  import { useNumberNotation } from '../client-context.js';
10
+ import {} from '../number-notation.js';
10
11
  import { useDatabaseResources } from '../use-database-resources.js';
11
12
  import { usePopupPress } from '../use-popup-press.js';
12
13
  import { useStableCallback } from '../use-stable-callback.js';
@@ -297,7 +298,6 @@ export function DataGrid({ columns, rows, label, editable = false, selectedKeys,
297
298
  onCommit?.(row.key, menuCell.column, value);
298
299
  }
299
300
  };
300
- /* The cells from row `top` to `bottom` in the given columns, with the whole value of every preview `loadValue` can fetch. */
301
301
  const wholeCellsOf = async (top, bottom, indexes) => {
302
302
  const shown = rows.slice(top, bottom + 1);
303
303
  const whole = await loadWholeCells(shown.map((row) => indexes.map((index) => row.cells[index] ?? null)), loadValue === undefined ? undefined : (row, column) => loadValue(shown[row].key, indexes[column]));
@@ -1,6 +1,6 @@
1
1
  import { type Ref } from 'react';
2
2
  import { type EnumType } from './enum-type.ts';
3
- export interface EnumPickerProps {
3
+ interface EnumPickerProps {
4
4
  type: EnumType;
5
5
  value: string | null;
6
6
  nullable: boolean;
@@ -15,3 +15,4 @@ export interface EnumPickerProps {
15
15
  ref?: Ref<HTMLButtonElement>;
16
16
  }
17
17
  export declare function EnumPicker({ type, value, nullable, label, autoOpen, disabled, onDone, look, className, ref }: EnumPickerProps): import("react").JSX.Element;
18
+ export {};
@@ -10,12 +10,10 @@ import { keyLabelOf } from '../column-keys.js';
10
10
  import { KeyIcon } from '../KeyIcon.js';
11
11
  import { isNumericKind } from '../sql.js';
12
12
  import { isDoubleClick, MAX_RESIZED_WIDTH, MIN_COLUMN_WIDTH } from './layout.js';
13
- /* The items of the menu a header opens, from its button and from a right click. */
14
13
  function HeaderMenuItems({ column, index, sortable, hasSorts, pinned, hasHidden, canHide, actions }) {
15
14
  const { t } = useTranslation('database');
16
15
  return (_jsxs(_Fragment, { children: [sortable && (_jsxs(_Fragment, { children: [_jsxs(Menu.Item, { onClick: () => actions.onSortDirection(index, 'asc'), children: [_jsx(Icon, { icon: ArrowUp, size: 14 }), t('grid.column.sortAscending')] }), _jsxs(Menu.Item, { onClick: () => actions.onSortDirection(index, 'desc'), children: [_jsx(Icon, { icon: ArrowDown, size: 14 }), t('grid.column.sortDescending')] }), _jsxs(Menu.Item, { disabled: !hasSorts, onClick: actions.onClearSort, children: [_jsx(Icon, { icon: ArrowUpDown, size: 14 }), t('grid.column.clearSorting')] }), _jsx(Menu.Separator, {})] })), _jsxs(Menu.Item, { disabled: !canHide, onClick: () => actions.onHide(index), children: [_jsx(Icon, { icon: EyeOff, size: 14 }), t('grid.column.hide')] }), hasHidden && (_jsxs(Menu.Item, { onClick: actions.onShowAll, children: [_jsx(Icon, { icon: Eye, size: 14 }), t('grid.column.showAll')] })), _jsxs(Menu.Item, { onClick: () => actions.onTogglePin(index), children: [_jsx(Icon, { icon: pinned ? PinOff : Pin, size: 14 }), t(pinned ? 'grid.column.unpin' : 'grid.column.pin')] }), _jsx(Menu.Separator, {}), _jsxs(Menu.Item, { onClick: () => copyText(column.name), children: [_jsx(Icon, { icon: Copy, size: 14 }), t('grid.column.copyName')] })] }));
17
16
  }
18
- /* The facts about a table column that a tooltip can carry: its type, whether it takes NULL, its default. */
19
17
  function ColumnFacts({ column }) {
20
18
  const { t } = useTranslation('database');
21
19
  const keys = { primaryKey: column.primaryKey === true, foreignKey: column.foreignKey === true };
@@ -28,7 +26,6 @@ function ColumnFacts({ column }) {
28
26
  ].filter((fact) => fact !== null);
29
27
  return (_jsxs(_Fragment, { children: [_jsx("span", { className: "block", children: column.name }), facts.length > 0 && _jsx("span", { className: "block", children: facts.join(', ') })] }));
30
28
  }
31
- /* 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. */
32
29
  export function GridHeaderCell({ column, index, position, width, sortable, selected, id, sort, multipleSorts, hasSorts, pinned, lastPinned, last, hasHidden, canHide, actions }) {
33
30
  const { t } = useTranslation('database');
34
31
  const cell = useRef(null);
@@ -1,6 +1,6 @@
1
1
  import { type MouseEvent, type PointerEvent } from 'react';
2
+ import { type NumberNotation } from '../number-notation.ts';
2
3
  import { type EditMove } from './CellEditor.tsx';
3
- import { type NumberNotation } from './display.ts';
4
4
  import type { EnumType } from './enum-type.ts';
5
5
  import type { CellPosition } from './navigation.ts';
6
6
  import type { GridColumn, GridRow } from './types.ts';
@@ -35,7 +35,7 @@ export interface RowActions {
35
35
  finishEdit(commit: boolean, move?: EditMove): void;
36
36
  changeDraft(draft: string): void;
37
37
  }
38
- export interface GridRowViewProps {
38
+ interface GridRowViewProps {
39
39
  row: GridRow;
40
40
  index: number;
41
41
  selected: boolean;
@@ -47,3 +47,4 @@ export interface GridRowViewProps {
47
47
  actions: RowActions;
48
48
  }
49
49
  export declare const GridRowView: import("react").MemoExoticComponent<({ row, index, selected, focusedColumn, rangeStart, rangeEnd, editing, look, actions }: GridRowViewProps) => import("react").JSX.Element>;
50
+ export {};
@@ -4,6 +4,7 @@ import { formatNumber } from '@adecore/ui/format';
4
4
  import clsx from 'clsx';
5
5
  import { memo } from 'react';
6
6
  import { CODE_TEXT } from '../code-text.js';
7
+ import {} from '../number-notation.js';
7
8
  import { cellIdOf } from './cell-id.js';
8
9
  import { CellEditor } from './CellEditor.js';
9
10
  import { columnNotation, cellView } from './display.js';
@@ -1,7 +1,5 @@
1
1
  import { type ReactNode, type Ref } from 'react';
2
- export declare const VALUE_PANEL_WIDTH = 320;
3
- export declare const VALUE_PANEL_MIN_WIDTH = 240;
4
- export interface ValueDockProps {
2
+ interface ValueDockProps {
5
3
  open: boolean;
6
4
  panel: ReactNode;
7
5
  children: ReactNode;
@@ -11,3 +9,4 @@ export interface ValueDockProps {
11
9
  ref?: Ref<HTMLDivElement>;
12
10
  }
13
11
  export declare function ValueDock({ open, panel, children, width: given, onWidthChange, className, ref }: ValueDockProps): import("react").JSX.Element;
12
+ export {};
@@ -3,9 +3,8 @@ import { ColumnResizeHandle, useColumnResize } from '@adecore/ui';
3
3
  import clsx from 'clsx';
4
4
  import { useRef, useState } from 'react';
5
5
  import { assignRef } from '../assign-ref.js';
6
- export const VALUE_PANEL_WIDTH = 320;
7
- export const VALUE_PANEL_MIN_WIDTH = 240;
8
- /* A grid with a panel along its right edge that a person can widen by its left edge. */
6
+ const VALUE_PANEL_WIDTH = 320;
7
+ const VALUE_PANEL_MIN_WIDTH = 240;
9
8
  export function ValueDock({ open, panel, children, width: given, onWidthChange, className, ref }) {
10
9
  const root = useRef(null);
11
10
  const dock = useRef(null);
@@ -5,7 +5,7 @@ export interface RangeBlock {
5
5
  readonly bottom: number;
6
6
  readonly columns: readonly number[];
7
7
  }
8
- export interface NumericAggregates {
8
+ interface NumericAggregates {
9
9
  readonly count: number;
10
10
  readonly sum: number;
11
11
  readonly average: number;
@@ -20,3 +20,4 @@ export interface Aggregates {
20
20
  }
21
21
  export declare const blockSize: (block: RangeBlock) => number;
22
22
  export declare const aggregateBlock: (rows: readonly (readonly Shown[])[], kinds: readonly ValueKind[], block: RangeBlock) => Aggregates;
23
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { CellPosition } from './navigation.ts';
2
- export interface CellRect {
2
+ interface CellRect {
3
3
  readonly top: number;
4
4
  readonly bottom: number;
5
5
  readonly left: number;
@@ -12,3 +12,4 @@ export declare const rectSize: (rect: CellRect) => {
12
12
  rows: number;
13
13
  columns: number;
14
14
  };
15
+ export {};
@@ -1,4 +1,3 @@
1
- /* The block between two cells, whichever corner each one is. */
2
1
  export const rectBetween = (from, to) => ({
3
2
  top: Math.min(from.row, to.row),
4
3
  bottom: Math.max(from.row, to.row),
@@ -6,6 +5,5 @@ export const rectBetween = (from, to) => ({
6
5
  right: Math.max(from.column, to.column)
7
6
  });
8
7
  export const rectContains = (rect, row, column) => rect !== null && row >= rect.top && row <= rect.bottom && column >= rect.left && column <= rect.right;
9
- /* Every cell of a grid, or `null` when it has none. */
10
8
  export const fullRect = (rows, columns) => rows === 0 || columns === 0 ? null : { top: 0, bottom: rows - 1, left: 0, right: columns - 1 };
11
9
  export const rectSize = (rect) => ({ rows: rect.bottom - rect.top + 1, columns: rect.right - rect.left + 1 });
@@ -4,7 +4,7 @@ export interface GridLayout {
4
4
  readonly hidden: readonly string[];
5
5
  readonly pinned: readonly string[];
6
6
  }
7
- export interface ColumnState {
7
+ interface ColumnState {
8
8
  readonly resized: Readonly<Record<number, number>>;
9
9
  readonly view: ColumnView;
10
10
  }
@@ -15,3 +15,4 @@ export declare const captureLayout: (columns: readonly {
15
15
  readonly name: string;
16
16
  }[], state: ColumnState) => GridLayout;
17
17
  export declare const sameLayout: (a: GridLayout, b: GridLayout) => boolean;
18
+ export {};
@@ -24,7 +24,6 @@ export const restoreLayout = (columns, layout) => {
24
24
  }
25
25
  return { resized, view: { hidden: hidden.size >= columns.length ? new Set() : hidden, pinned } };
26
26
  };
27
- /* The layout of a grid's state, with the columns by name. */
28
27
  export const captureLayout = (columns, state) => {
29
28
  const widths = {};
30
29
  for (const [index, width] of Object.entries(state.resized)) {
@@ -24,5 +24,4 @@ export const selectColumn = (current, order, index, click) => {
24
24
  }
25
25
  return { columns: new Set([index]), anchor: index };
26
26
  };
27
- /* The picked columns that are drawn, in the order they are drawn. */
28
27
  export const shownSelection = (current, order) => order.filter((index) => current.columns.has(index));
@@ -1,6 +1,5 @@
1
1
  export const NO_COLUMN_VIEW = { hidden: new Set(), pinned: [] };
2
2
  const shownPins = (count, view) => view.pinned.filter((index) => index < count && !view.hidden.has(index));
3
- /* The columns to draw as indexes: the pinned ones first in pin order, then the rest as they come, hidden ones left out. */
4
3
  export const displayOrder = (count, view) => {
5
4
  const pinned = shownPins(count, view);
6
5
  const rest = [];
@@ -20,5 +19,4 @@ export const togglePin = (view, index) => ({
20
19
  ...view,
21
20
  pinned: view.pinned.includes(index) ? view.pinned.filter((pinned) => pinned !== index) : [...view.pinned, index]
22
21
  });
23
- /* How many of the first columns of `displayOrder` are pinned. */
24
22
  export const pinnedCount = (count, view) => shownPins(count, view).length;
@@ -3,7 +3,7 @@ import { type SqlTarget } from '../sql.ts';
3
3
  import { type Shown } from './display.ts';
4
4
  export type CopyFormat = 'tsv' | 'csv' | 'json' | 'sql';
5
5
  export declare const COPY_FORMATS: readonly CopyFormat[];
6
- export interface CopyColumn {
6
+ interface CopyColumn {
7
7
  readonly name: string;
8
8
  readonly kind: ValueKind;
9
9
  }
@@ -13,3 +13,4 @@ export interface CopyInput {
13
13
  readonly target?: SqlTarget;
14
14
  }
15
15
  export declare const formatCopy: (format: CopyFormat, input: CopyInput) => string;
16
+ export {};
@@ -1,16 +1,16 @@
1
+ import type { NumberNotation } from '../number-notation.ts';
1
2
  import type { Cell, EditValue, ValueKind } from '../protocol/index.ts';
2
3
  import type { GridColumn } from './types.ts';
3
4
  export type Shown = Cell | {
4
5
  readonly kind: 'default';
5
6
  };
6
- export type CellTone = 'value' | 'null' | 'default';
7
+ type CellTone = 'value' | 'null' | 'default';
7
8
  export interface CellView {
8
9
  readonly text: string;
9
10
  readonly tone: CellTone;
10
11
  readonly align: 'start' | 'end';
11
12
  readonly suffix?: string;
12
13
  }
13
- export type NumberNotation = 'database' | 'region';
14
14
  export declare const DISPLAY_LIMIT = 200;
15
15
  export declare const BINARY_PREVIEW_BYTES = 8;
16
16
  export declare const isPreview: (cell: Shown) => boolean;
@@ -19,3 +19,4 @@ export declare function columnNotation(column: GridColumn, notation: NumberNotat
19
19
  export declare const cellView: (cell: Shown, kind: ValueKind, notation?: NumberNotation) => CellView;
20
20
  export declare const copyTextOf: (cell: Shown) => string;
21
21
  export declare const shownOfEdit: (value: EditValue) => Shown;
22
+ export {};
@@ -2,11 +2,9 @@ import { formatBytes, formatNumeral } from '@adecore/ui/format';
2
2
  import { isNumericKind } from '../sql.js';
3
3
  /* A cell never draws more than this, however long the text, so the DOM stays small. The cell is one line anyway. */
4
4
  export const DISPLAY_LIMIT = 200;
5
- /* How many bytes of a binary value the cell spells out. */
6
5
  export const BINARY_PREVIEW_BYTES = 8;
7
6
  const ELLIPSIS = '…';
8
7
  const isObject = (cell) => cell !== null && typeof cell === 'object';
9
- /* Whether a cell is only the start of its value, so editing it needs the whole value first. */
10
8
  export const isPreview = (cell) => {
11
9
  if (!isObject(cell)) {
12
10
  return false;
@@ -16,7 +14,6 @@ export const isPreview = (cell) => {
16
14
  }
17
15
  return cell.kind === 'binary' && cell.hex.length < cell.length * 2;
18
16
  };
19
- /* A numeral in the notation asked for; text that is no numeral stays as it is. */
20
17
  export const numeralText = (numeral, notation) => {
21
18
  if (notation === 'database') {
22
19
  return String(numeral);
@@ -63,7 +60,6 @@ export const cellView = (cell, kind, notation = 'database') => {
63
60
  }
64
61
  }
65
62
  };
66
- /* The text a copy puts on the clipboard: the value as the cell has it, a preview as far as it goes. */
67
63
  export const copyTextOf = (cell) => {
68
64
  if (cell === null) {
69
65
  return 'NULL';
@@ -80,7 +76,6 @@ export const copyTextOf = (cell) => {
80
76
  return `0x${cell.hex}`;
81
77
  }
82
78
  };
83
- /* An edit as a cell, so the grid draws a pending value the way it draws a loaded one. */
84
79
  export const shownOfEdit = (value) => {
85
80
  if (value !== null && typeof value === 'object' && value.kind === 'binary') {
86
81
  return { kind: 'binary', hex: value.hex, length: value.hex.length / 2 };
@@ -2,7 +2,6 @@
2
2
  const EMPTY_IS_NULL = new Set(['integer', 'decimal', 'float', 'boolean', 'date', 'time', 'datetime', 'binary']);
3
3
  const INTEGER = /^[+-]?\d+$/;
4
4
  const HEX = /^0x([0-9a-f]*)$/i;
5
- /* The text an editor starts with for a value that is whole (a preview has to be loaded first). */
6
5
  export const draftOf = (value) => {
7
6
  if (value === null) {
8
7
  return '';
@@ -46,7 +46,6 @@ export const parseEnumType = (type) => {
46
46
  return null;
47
47
  };
48
48
  const tidy = (kind, values) => values.length === 0 ? null : { kind: kind.toLowerCase() === 'set' ? 'set' : 'enum', values };
49
- /* The members a SET value holds: the text split on commas, empty for the empty set. */
50
49
  export const membersOf = (value) => (value === '' ? [] : value.split(','));
51
50
  /* A SET value in the order of the column's values, which is the order the server writes it in. */
52
51
  export const joinMembers = (type, members) => type.values.filter((value) => members.has(value)).join(',');
@@ -1,7 +1,6 @@
1
1
  import { valueOfCell } from '../protocol/index.js';
2
2
  /* The whole value of a cell, or `undefined` when it is only a preview (or a pending DEFAULT, which holds no value). */
3
3
  export const wholeValueOf = (cell) => cell !== null && typeof cell === 'object' && cell.kind === 'default' ? undefined : valueOfCell(cell);
4
- /* What a cell holds as far as it goes: the whole value, or the preview of a long text or a binary value. */
5
4
  export const previewValueOf = (cell) => {
6
5
  const whole = wholeValueOf(cell);
7
6
  if (whole !== undefined) {
@@ -5,9 +5,8 @@ export declare const MAX_COLUMN_WIDTH = 320;
5
5
  export declare const MAX_RESIZED_WIDTH = 1200;
6
6
  export declare const MAX_FIT_WIDTH = 640;
7
7
  export declare const ROW_BLOCK = 16;
8
- export declare const DOUBLE_CLICK_MS = 350;
9
8
  export declare const FALLBACK_VIEWPORT_HEIGHT = 600;
10
- export interface VisibleRange {
9
+ interface VisibleRange {
11
10
  readonly start: number;
12
11
  readonly end: number;
13
12
  }
@@ -21,3 +20,4 @@ export declare const estimateColumnWidth: (header: string, samples: readonly str
21
20
  export declare const fitColumnWidth: (header: string, texts: readonly string[], keyed: boolean) => number;
22
21
  export declare const isDoubleClick: (previous: number | null, now: number) => boolean;
23
22
  export declare const growWidths: (previous: readonly number[], next: readonly number[]) => number[];
23
+ export {};
@@ -5,12 +5,10 @@ export const MIN_COLUMN_WIDTH = 64;
5
5
  export const MAX_COLUMN_WIDTH = 320;
6
6
  /* How far a drag may widen a column; the estimate stops at `MAX_COLUMN_WIDTH`, a person may go further. */
7
7
  export const MAX_RESIZED_WIDTH = 1200;
8
- /* How wide fitting a column to its content may make it. */
9
8
  export const MAX_FIT_WIDTH = 640;
10
9
  /* The window of drawn rows moves in blocks of this many rows, so a scroll within a block draws nothing. */
11
10
  export const ROW_BLOCK = 16;
12
- /* Two presses on a resize handle this close are a double click. */
13
- export const DOUBLE_CLICK_MS = 350;
11
+ const DOUBLE_CLICK_MS = 350;
14
12
  /* What a viewport is taken to be until it is measured, so a first paint already holds rows. */
15
13
  export const FALLBACK_VIEWPORT_HEIGHT = 600;
16
14
  /* A glyph of the 13px mono face is 7.8px wide; a whole pixel on the safe side. */
@@ -21,7 +19,6 @@ const GUTTER_MIN_WIDTH = 40;
21
19
  const SAMPLE_ROWS = 50;
22
20
  /* The arrow and the position number a sorted header carries after its name. */
23
21
  const SORT_ROOM = 24;
24
- /* The block the top of the viewport is in, for a viewport `top` pixels into the rows. */
25
22
  export const scrollBlock = (top) => Math.floor(Math.max(0, top) / (ROW_BLOCK * ROW_HEIGHT));
26
23
  /*
27
24
  * The rows to draw while the top of a viewport `height` pixels tall is in `block`: those in view and a
@@ -51,7 +48,6 @@ export const scrollToReveal = (start, size, scroll, viewport, leading) => {
51
48
  }
52
49
  return scroll;
53
50
  };
54
- /* The left edge of every column, counted from the first one. */
55
51
  export const columnOffsets = (widths) => {
56
52
  let offset = 0;
57
53
  return widths.map((width) => {
@@ -60,15 +56,11 @@ export const columnOffsets = (widths) => {
60
56
  return left;
61
57
  });
62
58
  };
63
- /* Wide enough for the largest row number, never narrower than `GUTTER_MIN_WIDTH`. */
64
59
  export const gutterWidth = (rowCount) => Math.max(GUTTER_MIN_WIDTH, String(Math.max(rowCount, 1)).length * CHARACTER_WIDTH + CELL_PADDING);
65
60
  export const clampColumnWidth = (width) => Math.max(MIN_COLUMN_WIDTH, Math.min(Math.ceil(width), MAX_COLUMN_WIDTH));
66
61
  const bodyWidth = (texts) => texts.reduce((longest, text) => Math.max(longest, text.length), 0) * CHARACTER_WIDTH;
67
- /* `keyed` makes room for the key icon in front of the name. */
68
62
  const headerWidth = (header, keyed) => header.length * CHARACTER_WIDTH + (keyed ? KEY_ICON_ROOM : 0) + SORT_ROOM;
69
- /* From the longest text among the header and the first rows. */
70
63
  export const estimateColumnWidth = (header, samples, keyed) => clampColumnWidth(Math.max(bodyWidth(samples.slice(0, SAMPLE_ROWS)), headerWidth(header, keyed)) + CELL_PADDING);
71
- /* Wide enough for the header and every text of the column, up to `MAX_FIT_WIDTH`. */
72
64
  export const fitColumnWidth = (header, texts, keyed) => Math.max(MIN_COLUMN_WIDTH, Math.min(Math.ceil(Math.max(bodyWidth(texts), headerWidth(header, keyed)) + CELL_PADDING), MAX_FIT_WIDTH));
73
65
  export const isDoubleClick = (previous, now) => previous !== null && now - previous <= DOUBLE_CLICK_MS;
74
66
  /*
@@ -2,7 +2,7 @@ export interface CellPosition {
2
2
  readonly row: number;
3
3
  readonly column: number;
4
4
  }
5
- export interface GridSize {
5
+ interface GridSize {
6
6
  readonly rows: number;
7
7
  readonly columns: number;
8
8
  readonly page: number;
@@ -13,3 +13,4 @@ export interface NavigationKey {
13
13
  readonly mod: boolean;
14
14
  }
15
15
  export declare const moveFocus: (from: CellPosition | null, input: NavigationKey, size: GridSize) => CellPosition | null;
16
+ export {};
@@ -1,4 +1,3 @@
1
- /* Keys that, with no cell focused yet, only put the focus on the first one. */
2
1
  const ENTERING_KEYS = new Set(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageUp', 'PageDown', 'Tab']);
3
2
  const clamp = (value, max) => Math.max(0, Math.min(value, max - 1));
4
3
  /*
@@ -1,9 +1,10 @@
1
- export interface RowSelection {
1
+ interface RowSelection {
2
2
  readonly selected: ReadonlySet<string>;
3
3
  readonly anchor: number;
4
4
  }
5
- export interface RowClick {
5
+ interface RowClick {
6
6
  readonly shiftKey: boolean;
7
7
  readonly mod: boolean;
8
8
  }
9
9
  export declare const selectRow: (keys: readonly string[], current: ReadonlySet<string>, anchor: number, index: number, click: RowClick) => RowSelection;
10
+ export {};
package/dist/grid/sort.js CHANGED
@@ -1,6 +1,4 @@
1
- /* The column as the only sort, in a direction a menu picked. */
2
1
  export const sortOnly = (column, direction) => [{ column, direction }];
3
- /* The sort of a column and its place among the sorts counted from one, or `null` when it is not sorted. */
4
2
  export const sortStateOf = (sorts, column) => {
5
3
  const index = sorts.findIndex((sort) => sort.column === column);
6
4
  return index < 0 ? null : { direction: sorts[index].direction, position: index + 1 };
@@ -1,4 +1,3 @@
1
- /* Builds the column of a table from the result column, the structure's column of the same name and the columns of its keys. */
2
1
  export const gridColumnOf = (column, info, keys) => ({
3
2
  ...column,
4
3
  primaryKey: keys.primaryKey.includes(column.name),
@@ -1,9 +1,10 @@
1
1
  import type { Value } from '../protocol/index.ts';
2
2
  import { type Shown } from './display.ts';
3
3
  export declare const WHOLE_COPY_LIMIT: number;
4
- export interface WholeCells {
4
+ interface WholeCells {
5
5
  readonly rows: readonly (readonly Shown[])[];
6
6
  readonly previews: number;
7
7
  readonly tooLarge: boolean;
8
8
  }
9
9
  export declare const loadWholeCells: (rows: readonly (readonly Shown[])[], load: ((row: number, column: number) => Promise<Value | undefined>) | undefined) => Promise<WholeCells>;
10
+ export {};
@@ -5,4 +5,5 @@ export interface HelperPathOptions {
5
5
  readonly resolve?: (specifier: string) => string;
6
6
  readonly exists?: (path: string) => boolean;
7
7
  }
8
+ export declare const helperFileName: (platform?: string) => string;
8
9
  export declare const helperPath: ({ platform, arch, env, resolve, exists }?: HelperPathOptions) => string | null;
@@ -2,6 +2,8 @@ import { existsSync } from 'node:fs';
2
2
  import { createRequire } from 'node:module';
3
3
  import { dirname, join, sep } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
+ /* The file name of the helper binary, which an app that packages it beside its own binary has to use as well. */
6
+ export const helperFileName = (platform = process.platform) => (platform === 'win32' ? 'adecore-database.exe' : 'adecore-database');
5
7
  /*
6
8
  * Finds the helper for this machine, or null when there is none. In order: the path in `ADECORE_DATABASE_HELPER`;
7
9
  * the prebuilt binary npm installed in the `@adecore/database-<platform>-<arch>` package, absent on an
@@ -18,7 +20,7 @@ export const helperPath = ({ platform = process.platform, arch = process.arch, e
18
20
  if (override) {
19
21
  return override;
20
22
  }
21
- const binary = platform === 'win32' ? 'adecore-database.exe' : 'adecore-database';
23
+ const binary = helperFileName(platform);
22
24
  return packagedHelper(platform, arch, binary, resolve, exists) ?? checkoutHelper(binary, exists);
23
25
  };
24
26
  const packagedHelper = (platform, arch, binary, resolve, exists) => {