@antelopejs/dms-database 0.2.3 → 0.3.1

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 (42) hide show
  1. package/README.md +4 -4
  2. package/dist/frontend-module.d.ts +2 -0
  3. package/dist/frontend-module.js +17 -0
  4. package/dist/frontend-module.js.map +1 -0
  5. package/dist/index.js +2 -11
  6. package/dist/index.js.map +1 -1
  7. package/dist/pages/overview.d.ts +0 -1
  8. package/dist/pages/overview.js +0 -14
  9. package/dist/pages/overview.js.map +1 -1
  10. package/dist/pages/schemas.js +3 -0
  11. package/dist/pages/schemas.js.map +1 -1
  12. package/frontend-vue/app/build/composables/useDatabaseHealth.ts +11 -7
  13. package/frontend-vue/app/build/composables/useDatabaseSchemas.ts +8 -1
  14. package/frontend-vue/app/build/data/cellValues.ts +50 -0
  15. package/frontend-vue/app/build/diagram/graph.ts +211 -47
  16. package/frontend-vue/app/build/diagram/packing.ts +283 -0
  17. package/frontend-vue/app/build/utils/fieldTypes.ts +16 -1
  18. package/frontend-vue/app/components/ConnectionStatus.vue +5 -1
  19. package/frontend-vue/app/components/DataBrowser.vue +2 -2
  20. package/frontend-vue/app/components/DataBrowserSidebar.vue +1 -1
  21. package/frontend-vue/app/components/DataGrid.vue +44 -34
  22. package/frontend-vue/app/components/DiagramTableNode.vue +25 -1
  23. package/frontend-vue/app/components/DrawerTabs.vue +57 -0
  24. package/frontend-vue/app/components/JsonCellPanel.vue +81 -85
  25. package/frontend-vue/app/components/QueryConsole.vue +6 -1
  26. package/frontend-vue/app/components/RowDrawer.vue +98 -124
  27. package/frontend-vue/app/components/SchemaDiagram.vue +134 -17
  28. package/frontend-vue/app/components/TableInspector.vue +122 -149
  29. package/frontend-vue/i18n/locales/database-en-GB.json +8 -12
  30. package/frontend-vue/i18n/locales/database-fr-FR.json +8 -12
  31. package/frontend-vue/package.json +2 -2
  32. package/frontend-vue/pnpm-lock.yaml +5 -5
  33. package/frontend-vue/tests/clientNavigation.test.ts +93 -0
  34. package/frontend-vue/tests/dataBrowser.test.ts +91 -1
  35. package/frontend-vue/tests/diagramLayout.test.ts +383 -0
  36. package/frontend-vue/tests/fixtures/serverRender.ts +114 -0
  37. package/frontend-vue/tests/locales.test.ts +48 -0
  38. package/frontend-vue/tests/onDemandReads.test.ts +81 -0
  39. package/frontend-vue/tests/serverRender.test.ts +83 -1
  40. package/frontend-vue/vitest.config.ts +8 -1
  41. package/package.json +9 -8
  42. package/skills/dms-database/SKILL.md +2 -1
@@ -5,12 +5,6 @@
5
5
  "overview": {
6
6
  "title": "Overview",
7
7
  "description": "Connection health, schemas and recent activity of the database.",
8
- "beta": {
9
- "title": "Beta",
10
- "body": "Saved edits in the data browser are written straight to the database. Structure editing (columns, indexes, relations) comes with the Module Builder.",
11
- "meta": "Beta notice",
12
- "meta_description": "The one-line notice about writes and what is coming."
13
- },
14
8
  "actions": {
15
9
  "query": "Open query console",
16
10
  "browse": "Browse data"
@@ -84,6 +78,7 @@
84
78
  "title": "Table",
85
79
  "meta": "Table inspector",
86
80
  "meta_description": "Columns, indexes, relations and a sample row of one table.",
81
+ "position": "Table {index} of {total}",
87
82
  "not_found": "Table not found"
88
83
  },
89
84
  "caption": "Tables",
@@ -225,10 +220,7 @@
225
220
  "rows_missing": "{count} row no longer exists. | {count} rows no longer exist."
226
221
  },
227
222
  "row": {
228
- "title": "Row of {table}",
229
- "eyebrow": "Row · {scope}",
230
- "previous": "Previous row (K)",
231
- "next": "Next row (J)",
223
+ "position": "Row {index} of {total}",
232
224
  "fields": "Fields",
233
225
  "json": "JSON",
234
226
  "references": "Referenced by",
@@ -306,6 +298,10 @@
306
298
  "focus": "Focus",
307
299
  "show_all": "Show all tables"
308
300
  },
301
+ "columns": {
302
+ "more": "+ {count} column | + {count} columns",
303
+ "fold": "Fold columns"
304
+ },
309
305
  "legend": {
310
306
  "key": "Primary key",
311
307
  "relation": "Relation",
@@ -491,8 +487,6 @@
491
487
  "inspector": {
492
488
  "load_error": "Couldn't load the schemas of this table.",
493
489
  "eyebrow": "Schema · {schema}",
494
- "previous": "Previous table (K)",
495
- "next": "Next table (J)",
496
490
  "instances": "{count} instance | {count} instances",
497
491
  "copy_name": "Copy table name",
498
492
  "copied": "{name} copied",
@@ -519,6 +513,8 @@
519
513
  "column": "Column",
520
514
  "type": "Type",
521
515
  "null": "Null",
516
+ "nullable": "yes",
517
+ "not_nullable": "no",
522
518
  "notes": "Notes"
523
519
  },
524
520
  "index": {
@@ -5,12 +5,6 @@
5
5
  "overview": {
6
6
  "title": "Vue d'ensemble",
7
7
  "description": "Santé de la connexion, schémas et activité récente de la base.",
8
- "beta": {
9
- "title": "Bêta",
10
- "body": "Les modifications enregistrées dans l'explorateur de données sont écrites directement en base. L'édition de la structure (colonnes, index, relations) arrive avec le Module Builder.",
11
- "meta": "Avertissement bêta",
12
- "meta_description": "L'avertissement d'une ligne sur les écritures et ce qui arrive."
13
- },
14
8
  "actions": {
15
9
  "query": "Ouvrir la console",
16
10
  "browse": "Parcourir les données"
@@ -84,6 +78,7 @@
84
78
  "title": "Table",
85
79
  "meta": "Inspecteur de table",
86
80
  "meta_description": "Colonnes, index, relations et ligne exemple d'une table.",
81
+ "position": "Table {index} sur {total}",
87
82
  "not_found": "Table introuvable"
88
83
  },
89
84
  "caption": "Tables",
@@ -225,10 +220,7 @@
225
220
  "rows_missing": "{count} ligne n'existe plus. | {count} lignes n'existent plus."
226
221
  },
227
222
  "row": {
228
- "title": "Ligne de {table}",
229
- "eyebrow": "Ligne · {scope}",
230
- "previous": "Ligne précédente (K)",
231
- "next": "Ligne suivante (J)",
223
+ "position": "Ligne {index} sur {total}",
232
224
  "fields": "Champs",
233
225
  "json": "JSON",
234
226
  "references": "Référencée par",
@@ -306,6 +298,10 @@
306
298
  "focus": "Isoler",
307
299
  "show_all": "Afficher toutes les tables"
308
300
  },
301
+ "columns": {
302
+ "more": "+ {count} colonne | + {count} colonnes",
303
+ "fold": "Replier les colonnes"
304
+ },
309
305
  "legend": {
310
306
  "key": "Clé primaire",
311
307
  "relation": "Relation",
@@ -491,8 +487,6 @@
491
487
  "inspector": {
492
488
  "load_error": "Impossible de charger les schémas de cette table.",
493
489
  "eyebrow": "Schéma · {schema}",
494
- "previous": "Table précédente (K)",
495
- "next": "Table suivante (J)",
496
490
  "instances": "{count} instance | {count} instances",
497
491
  "copy_name": "Copier le nom de la table",
498
492
  "copied": "{name} copié",
@@ -519,6 +513,8 @@
519
513
  "column": "Colonne",
520
514
  "type": "Type",
521
515
  "null": "Null",
516
+ "nullable": "oui",
517
+ "not_nullable": "non",
522
518
  "notes": "Notes"
523
519
  },
524
520
  "index": {
@@ -6,7 +6,7 @@
6
6
  "main": "./dms.frontend.ts",
7
7
  "packageManager": "pnpm@10.6.5",
8
8
  "engines": {
9
- "@antelopejs/dms-frontend": ">=0.6.3 <0.8.0"
9
+ "@antelopejs/dms-frontend": ">=0.9.0 <0.10.0"
10
10
  },
11
11
  "scripts": {
12
12
  "dev": "pnpm --dir ../playground frontend:dev",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@antelopejs/interface-core": ">=0.2.4 <1.0.0",
22
- "@antelopejs/interface-database": ">=0.1.10 <1.0.0",
22
+ "@antelopejs/interface-database": ">=0.1.11 <1.0.0",
23
23
  "@codemirror/autocomplete": "^6.18.6",
24
24
  "@codemirror/commands": "^6.8.1",
25
25
  "@codemirror/lang-javascript": "^6.2.4",
@@ -12,8 +12,8 @@ importers:
12
12
  specifier: '>=0.2.4 <1.0.0'
13
13
  version: 0.2.4
14
14
  '@antelopejs/interface-database':
15
- specifier: '>=0.1.10 <1.0.0'
16
- version: 0.1.10(@antelopejs/interface-core@0.2.4)
15
+ specifier: '>=0.1.11 <1.0.0'
16
+ version: 0.1.11(@antelopejs/interface-core@0.2.4)
17
17
  '@codemirror/autocomplete':
18
18
  specifier: ^6.18.6
19
19
  version: 6.20.3
@@ -88,8 +88,8 @@ packages:
88
88
  '@antelopejs/interface-core@0.2.4':
89
89
  resolution: {integrity: sha512-2qF6/KwahCQvvNuC/piUvPWD4wq2Npmco941HMg2/bMBoJKbhMH16WcXXRvPYznNSkU0U+6vqK6KE+2N5NojSA==}
90
90
 
91
- '@antelopejs/interface-database@0.1.10':
92
- resolution: {integrity: sha512-sT46GoSXvFTJpXA94toK1B3V+9YmZxjhyyCLhFNtvbijCehdtJCWILb3CbEnrWIWrlj/NPAKZ6ayH+wxUIdRWw==}
91
+ '@antelopejs/interface-database@0.1.11':
92
+ resolution: {integrity: sha512-uv6mB1Lghmlc9z+oWzntmzD1ZNBAmrj+2+7MItv6zClEolbqw5hfAt8+c3IPq2yLfWDfhpqWme2m0eTwsAm0RQ==}
93
93
  peerDependencies:
94
94
  '@antelopejs/interface-core': '>=0.2.4 <1.0.0'
95
95
 
@@ -3089,7 +3089,7 @@ snapshots:
3089
3089
  dependencies:
3090
3090
  reflect-metadata: 0.2.2
3091
3091
 
3092
- '@antelopejs/interface-database@0.1.10(@antelopejs/interface-core@0.2.4)':
3092
+ '@antelopejs/interface-database@0.1.11(@antelopejs/interface-core@0.2.4)':
3093
3093
  dependencies:
3094
3094
  '@antelopejs/interface-core': 0.2.4
3095
3095
 
@@ -0,0 +1,93 @@
1
+ import { describe, expect, it, vi } from 'vitest'
2
+ import { browserMount, type BackendRead } from './fixtures/serverRender'
3
+ import ConnectionStatus from '../app/components/ConnectionStatus.vue'
4
+ import QueryConsole from '../app/components/QueryConsole.vue'
5
+
6
+ // The CodeMirror editor mounts on a real DOM, which this mount has not; it
7
+ // reads nothing and does not decide when the page lands.
8
+ vi.mock('../app/components/QueryBuilderPanel.vue', () => ({
9
+ default: { name: 'QueryBuilderPanel', render: () => null },
10
+ }))
11
+
12
+ // A client navigation shows a page once its components' setups settle: the
13
+ // reads that decide a component's size are awaited there, so the page lands
14
+ // with them rather than growing (or swapping placeholders) after it.
15
+
16
+ const schema = (id: string) => ({
17
+ id,
18
+ options: {},
19
+ tables: [
20
+ { name: 'orders', fields: {}, indexes: {}, relations: [] },
21
+ { name: 'customers', fields: {}, indexes: {}, relations: [] },
22
+ ],
23
+ stats: { tableCount: 2, elementCount: 3, instanceCount: 0 },
24
+ instances: [],
25
+ })
26
+
27
+ function answer({ url }: BackendRead): unknown {
28
+ switch (url) {
29
+ case '/api/database/health':
30
+ return {
31
+ status: 'ok',
32
+ latencyMs: 3,
33
+ driver: 'MongoDB',
34
+ checkedAt: '2026-10-18T10:00:00.000Z',
35
+ storage: [],
36
+ }
37
+ case '/api/database/schemas':
38
+ return { schemas: [schema('shop')] }
39
+ default:
40
+ return { items: [] }
41
+ }
42
+ }
43
+
44
+ /** A backend whose answers wait for `release()`. */
45
+ function heldBackend(respond: (read: BackendRead) => unknown = answer) {
46
+ let release!: () => void
47
+ const released = new Promise<void>((resolve) => (release = resolve))
48
+ return {
49
+ respond: async (read: BackendRead) => {
50
+ await released
51
+ return respond(read)
52
+ },
53
+ release,
54
+ }
55
+ }
56
+
57
+ async function settle(): Promise<void> {
58
+ for (let turn = 0; turn < 10; turn++) await new Promise((r) => setTimeout(r))
59
+ }
60
+
61
+ async function isShown(shown: Promise<void>): Promise<boolean> {
62
+ let done = false
63
+ void shown.then(() => (done = true))
64
+ await settle()
65
+ return done
66
+ }
67
+
68
+ describe('client navigation: the page lands with what decides its size', () => {
69
+ it('overview connection: the first probe, not the empty health', async () => {
70
+ const backend = heldBackend()
71
+ const page = browserMount(ConnectionStatus, backend.respond)
72
+ expect(await isShown(page.shown)).toBe(false)
73
+
74
+ backend.release()
75
+ await page.shown
76
+ expect(page.text()).toContain('MongoDB')
77
+ })
78
+
79
+ it('query console: the first run examples and the library', async () => {
80
+ const backend = heldBackend()
81
+ const page = browserMount(QueryConsole, backend.respond)
82
+ expect(await isShown(page.shown)).toBe(false)
83
+
84
+ backend.release()
85
+ await page.shown
86
+ expect(page.reads.map((read) => read.url)).toContain(
87
+ '/api/database/schemas',
88
+ )
89
+ // The examples of the first schema's tables are in the empty result.
90
+ expect(page.text()).toContain('first_description')
91
+ expect(page.text()).toContain('shop.orders')
92
+ })
93
+ })
@@ -6,7 +6,14 @@ import {
6
6
  instanceChoiceOf,
7
7
  tabInstanceOf,
8
8
  } from '../app/build/composables/useDataBrowserTabs'
9
- import { cellLabel, draftText, parseDraft } from '../app/build/data/cellValues'
9
+ import {
10
+ cellLabel,
11
+ draftText,
12
+ isWideValue,
13
+ jsonDraftText,
14
+ parseDraft,
15
+ parseJsonDraft,
16
+ } from '../app/build/data/cellValues'
10
17
  import {
11
18
  changesOf,
12
19
  mayMoveRows,
@@ -18,6 +25,7 @@ import {
18
25
  instanceToUrl,
19
26
  tableLink,
20
27
  } from '../app/build/utils/databaseLinks'
28
+ import { describeField, valueDescriptor } from '../app/build/utils/fieldTypes'
21
29
 
22
30
  describe('cell drafts: null', () => {
23
31
  it('empties a cell of any type with null', () => {
@@ -101,6 +109,35 @@ describe('cell drafts: dates', () => {
101
109
  })
102
110
  })
103
111
 
112
+ describe('cell drafts: JSON', () => {
113
+ it('opens a structured cell as indented JSON', () => {
114
+ expect(jsonDraftText({ a: [1, 2] })).toBe(
115
+ JSON.stringify({ a: [1, 2] }, null, 2),
116
+ )
117
+ expect(jsonDraftText({ a: 1 }).split('\n')).toHaveLength(3)
118
+ const cyclic: Record<string, unknown> = {}
119
+ cyclic.self = cyclic
120
+ expect(jsonDraftText(cyclic)).toBe('')
121
+ })
122
+
123
+ it('takes an object, a list, or null to empty the cell', () => {
124
+ expect(parseJsonDraft('{"a":1}')).toEqual({ ok: true, value: { a: 1 } })
125
+ expect(parseJsonDraft('[1]')).toEqual({ ok: true, value: [1] })
126
+ expect(parseJsonDraft(' null ')).toEqual({ ok: true, value: null })
127
+ })
128
+
129
+ it('refuses a scalar, and invalid JSON with its parse detail', () => {
130
+ for (const draft of ['42', '"text"', 'true'])
131
+ expect(parseJsonDraft(draft)).toEqual({
132
+ ok: false,
133
+ reason: 'not_structured',
134
+ })
135
+ const invalid = parseJsonDraft('{"a":')
136
+ expect(invalid).toMatchObject({ ok: false, reason: 'invalid' })
137
+ expect(invalid.ok || invalid.detail).toBeTruthy()
138
+ })
139
+ })
140
+
104
141
  describe('staged writes', () => {
105
142
  const rows: [string, Record<string, unknown>][] = [
106
143
  ['a', { name: 'A' }],
@@ -262,3 +299,56 @@ describe('instance URL parameter', () => {
262
299
  expect(instanceBadge('eu', 'all')).toBe('@eu')
263
300
  })
264
301
  })
302
+
303
+ describe('row drawer', () => {
304
+ it('gives JSON and long or multi-line text the drawer width', () => {
305
+ expect(isWideValue({ city: 'Liège' })).toBe(true)
306
+ expect(isWideValue([1, 2])).toBe(true)
307
+ expect(isWideValue('x'.repeat(49))).toBe(true)
308
+ expect(isWideValue('line one\nline two')).toBe(true)
309
+ expect(isWideValue('x'.repeat(48))).toBe(false)
310
+ expect(isWideValue('open')).toBe(false)
311
+ expect(isWideValue(true)).toBe(false)
312
+ expect(isWideValue(null)).toBe(false)
313
+ expect(isWideValue(42)).toBe(false)
314
+ })
315
+ })
316
+
317
+ describe('column types', () => {
318
+ it('reads a nullable union as the type it holds, with its icon', () => {
319
+ const nullable = {
320
+ kind: 'union' as const,
321
+ members: [{ kind: 'string' as const }, { kind: 'null' as const }],
322
+ }
323
+ expect(describeField(valueDescriptor(nullable))).toEqual({
324
+ icon: 'i-ph-text-aa',
325
+ label: 'string',
326
+ })
327
+ const several = {
328
+ kind: 'union' as const,
329
+ members: [
330
+ { kind: 'string' as const },
331
+ { kind: 'number' as const },
332
+ { kind: 'undefined' as const },
333
+ ],
334
+ }
335
+ expect(describeField(valueDescriptor(several)).label).toBe(
336
+ 'string | number',
337
+ )
338
+ // Only null: nothing else to read it as.
339
+ const onlyNull = {
340
+ kind: 'union' as const,
341
+ members: [{ kind: 'null' as const }],
342
+ }
343
+ expect(valueDescriptor(onlyNull)).toBe(onlyNull)
344
+ })
345
+
346
+ it('draws a union with an icon of the Phosphor set', () => {
347
+ expect(
348
+ describeField({
349
+ kind: 'union',
350
+ members: [{ kind: 'string' }, { kind: 'number' }],
351
+ }).icon,
352
+ ).toBe('i-ph-arrows-split')
353
+ })
354
+ })