@antelopejs/dms-database 0.5.5 → 0.5.6-next.188.g9710e2a

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 (63) hide show
  1. package/dist/db/models/diagram_layouts.model.d.ts +3 -2
  2. package/dist/db/models/diagram_layouts.model.js +12 -4
  3. package/dist/db/models/diagram_layouts.model.js.map +1 -1
  4. package/dist/db/models/diagram_notes.model.d.ts +2 -1
  5. package/dist/db/models/diagram_notes.model.js +10 -2
  6. package/dist/db/models/diagram_notes.model.js.map +1 -1
  7. package/dist/db/tables/diagram_layouts.table.d.ts +1 -0
  8. package/dist/db/tables/diagram_layouts.table.js +4 -0
  9. package/dist/db/tables/diagram_layouts.table.js.map +1 -1
  10. package/dist/db/tables/diagram_notes.table.d.ts +1 -0
  11. package/dist/db/tables/diagram_notes.table.js +4 -0
  12. package/dist/db/tables/diagram_notes.table.js.map +1 -1
  13. package/dist/pages/schemas.js +2 -4
  14. package/dist/pages/schemas.js.map +1 -1
  15. package/dist/routes/connections.d.ts +4 -0
  16. package/dist/routes/connections.js +23 -0
  17. package/dist/routes/connections.js.map +1 -1
  18. package/dist/routes/data.d.ts +0 -1
  19. package/dist/routes/diagram.d.ts +4 -4
  20. package/dist/routes/diagram.js +50 -31
  21. package/dist/routes/diagram.js.map +1 -1
  22. package/dist/service/browse.d.ts +1 -6
  23. package/dist/service/browse.js +43 -102
  24. package/dist/service/browse.js.map +1 -1
  25. package/dist/service/catalogReferences.d.ts +4 -0
  26. package/dist/service/catalogReferences.js +33 -0
  27. package/dist/service/catalogReferences.js.map +1 -0
  28. package/dist/service/connectionState.d.ts +1 -1
  29. package/dist/service/connectionState.js +0 -2
  30. package/dist/service/connectionState.js.map +1 -1
  31. package/dist/service/database.d.ts +2 -1
  32. package/dist/service/database.js +3 -2
  33. package/dist/service/database.js.map +1 -1
  34. package/dist/service/rowFilter.d.ts +17 -0
  35. package/dist/service/rowFilter.js +95 -0
  36. package/dist/service/rowFilter.js.map +1 -0
  37. package/dist/types/constants.d.ts +1 -0
  38. package/dist/types/constants.js +2 -1
  39. package/dist/types/constants.js.map +1 -1
  40. package/dist/utils/query.d.ts +0 -1
  41. package/dist/utils/query.js +0 -18
  42. package/dist/utils/query.js.map +1 -1
  43. package/frontend-vue/app/build/components/DataGridFooter.vue +0 -13
  44. package/frontend-vue/app/build/components/SchemaDiagramBoard.vue +17 -13
  45. package/frontend-vue/app/build/composables/useCatalogReferences.ts +68 -0
  46. package/frontend-vue/app/build/composables/useDataBrowserGrid.ts +0 -1
  47. package/frontend-vue/app/build/composables/useDatabaseConnections.ts +0 -1
  48. package/frontend-vue/app/build/composables/useDiagramPersistence.ts +12 -2
  49. package/frontend-vue/app/build/composables/useLockedPages.ts +0 -1
  50. package/frontend-vue/app/build/data/gridData.ts +0 -6
  51. package/frontend-vue/app/components/DataGrid.vue +0 -2
  52. package/frontend-vue/app/components/SchemaDiagram.vue +2 -8
  53. package/frontend-vue/app/components/TableInspector.vue +0 -1
  54. package/frontend-vue/i18n/locales/database-en-GB.json +1 -2
  55. package/frontend-vue/i18n/locales/database-fr-FR.json +1 -2
  56. package/frontend-vue/tests/databaseSwitcher.test.ts +2 -6
  57. package/frontend-vue/tests/diagramWrites.test.ts +46 -0
  58. package/frontend-vue/tests/externalBrowser.test.ts +0 -47
  59. package/frontend-vue/tests/fixtures/connections.ts +1 -1
  60. package/frontend-vue/tests/lockedPages.test.ts +35 -15
  61. package/frontend-vue/tests/onDemandReads.test.ts +2 -2
  62. package/frontend-vue/tests/serverRender.test.ts +2 -2
  63. package/package.json +2 -2
@@ -1,4 +1,6 @@
1
1
  <script setup lang="ts">
2
+ import { useCatalogReferences } from '../composables/useCatalogReferences'
3
+ import { useDatabaseConnections } from '../composables/useDatabaseConnections'
2
4
  import { useDatabaseSchemas } from '../composables/useDatabaseSchemas'
3
5
  import { useDiagramDrag } from '../composables/useDiagramDrag'
4
6
  import { useDiagramNotes } from '../composables/useDiagramNotes'
@@ -62,7 +64,9 @@ const route = useDmsRoute()
62
64
  const router = useDmsRouter()
63
65
  const toast = useToast()
64
66
  const { schemas, isLoading: schemasLoading } = useDatabaseSchemas()
65
- const persistence = useDiagramPersistence()
67
+ const { selected } = useDatabaseConnections()
68
+ const persistence = useDiagramPersistence(() => selected.value?.id)
69
+ const catalog = useCatalogReferences()
66
70
  const { open: openDrawer } = useDrawer()
67
71
 
68
72
  const canvas = shallowRef<ShallowUnwrapRef<VueFlowStore> | null>(null)
@@ -111,8 +115,8 @@ const schemaId = computed<string | null>(() => {
111
115
  return asked
112
116
  return schemas.value[0]?.id ?? null
113
117
  })
114
- const schema = computed(
115
- () => schemas.value.find((s) => s.id === schemaId.value) ?? null,
118
+ const schema = computed(() =>
119
+ catalog.apply(schemas.value.find((s) => s.id === schemaId.value) ?? null),
116
120
  )
117
121
  const schemaItems = computed(() =>
118
122
  schemas.value.map((s) => ({ label: s.id, value: s.id, icon: 'i-ph-stack' })),
@@ -316,16 +320,16 @@ async function load(id: string) {
316
320
  sync = owner
317
321
  await leaving
318
322
  if (sync !== owner) return
319
- try {
320
- const stored = await persistence.readDiagram(id)
321
- if (sync !== owner) return
322
- state.positions = stored.positions
323
- state.notes = stored.notes.map(noteFromStored)
324
- } catch {
325
- if (sync !== owner) return
326
- state.positions = {}
327
- state.notes = []
328
- }
323
+ const [stored, relations] = await Promise.all([
324
+ persistence.readDiagram(id).catch(() => null),
325
+ catalog.read(selected.value, id),
326
+ ])
327
+ if (sync !== owner) return
328
+ if (relations === undefined)
329
+ warn(t('dms_database.diagram.references_failed', { schema: id }))
330
+ state.positions = stored?.positions ?? {}
331
+ state.notes = stored?.notes.map(noteFromStored) ?? []
332
+ catalog.keep(relations)
329
333
  expanded.value = expandedBySchema.get(id) ?? new Set()
330
334
  layoutBasis.value = currentLayoutBasis()
331
335
  owner.reset(state)
@@ -0,0 +1,68 @@
1
+ import { type DatabaseConnection, isExternal } from './useDatabaseConnections'
2
+ import type { RelationDeclaration, SchemaSummary } from './useDatabaseSchemas'
3
+
4
+ /** The relations of each table of a schema, by table name. */
5
+ export type RelationsByTable = Record<string, RelationDeclaration[]>
6
+
7
+ const REQUEST_TIMEOUT_MS = 15_000
8
+
9
+ /**
10
+ * A schema with the relations a catalog reports in place of its declared
11
+ * ones; the schema as declared when there are none to apply.
12
+ */
13
+ export function withCatalogRelations(
14
+ schema: SchemaSummary | null,
15
+ relations: RelationsByTable | null,
16
+ ): SchemaSummary | null {
17
+ if (!schema || !relations) return schema
18
+ return {
19
+ ...schema,
20
+ tables: schema.tables.map((table) => ({
21
+ ...table,
22
+ relations: relations[table.name] ?? [],
23
+ })),
24
+ }
25
+ }
26
+
27
+ /**
28
+ * The foreign keys an external database's catalog reports out of the tables
29
+ * of the schema the diagram shows, as the relations it draws: an external
30
+ * schema declares none of its own.
31
+ */
32
+ export function useCatalogReferences() {
33
+ const { $authFetch } = useAuthFetch()
34
+ /**
35
+ * The shown schema's foreign keys by table; null on the project's own
36
+ * database, whose schema declares its relations.
37
+ */
38
+ const relations = shallowRef<RelationsByTable | null>(null)
39
+
40
+ return {
41
+ /**
42
+ * Reads a schema's foreign keys by table: `null` on the project's own
43
+ * database, and `undefined` when the catalog did not answer.
44
+ */
45
+ async read(
46
+ connection: DatabaseConnection | undefined,
47
+ schema: string,
48
+ ): Promise<RelationsByTable | null | undefined> {
49
+ if (!isExternal(connection)) return null
50
+ try {
51
+ const { tables } = await $authFetch<{ tables: RelationsByTable }>(
52
+ `/api/database/connections/${encodeURIComponent(connection.id)}/schemas/${encodeURIComponent(schema)}/references`,
53
+ { timeout: REQUEST_TIMEOUT_MS },
54
+ )
55
+ return tables
56
+ } catch {
57
+ return undefined
58
+ }
59
+ },
60
+ /** Shows what a read answered: no relation at all when the catalog did not answer. */
61
+ keep(read: RelationsByTable | null | undefined) {
62
+ relations.value = read === undefined ? {} : read
63
+ },
64
+ /** The schema with the kept relations in place of its declared ones. */
65
+ apply: (schema: SchemaSummary | null) =>
66
+ withCatalogRelations(schema, relations.value),
67
+ }
68
+ }
@@ -31,7 +31,6 @@ export interface GridData {
31
31
  rows: Record<string, unknown>[]
32
32
  total: number
33
33
  primaryKey: string | null
34
- capped: boolean
35
34
  }
36
35
 
37
36
  export const GRID_PAGE_SIZES = [25, 50, 100, 200]
@@ -2,7 +2,6 @@ import { reloadForSelection } from './reloadForSelection'
2
2
 
3
3
  /** A part of the console an external database cannot serve. */
4
4
  export type ConnectionFeature =
5
- | 'diagram'
6
5
  | 'queryConsole'
7
6
  | 'instances'
8
7
  | 'rowReferences'
@@ -44,8 +44,15 @@ const BASE = '/api/database/diagram'
44
44
  // canvas shows the error and its "Try again" instead of "Saving…" forever.
45
45
  const REQUEST_TIMEOUT_MS = 15_000
46
46
 
47
- export function useDiagramPersistence() {
47
+ /**
48
+ * Reads and writes the stored diagrams.
49
+ *
50
+ * @param connection The database this page loaded with: a write names it,
51
+ * and the server refuses it once another tab selected another database.
52
+ */
53
+ export function useDiagramPersistence(connection: () => string | undefined) {
48
54
  const { $authFetch } = useAuthFetch()
55
+ const written = () => ({ connection: connection() })
49
56
 
50
57
  // The schema whose diagram is read: in the browser only, when the canvas
51
58
  // asks, since it draws and edits a working copy of it.
@@ -98,6 +105,7 @@ export function useDiagramPersistence() {
98
105
  `${BASE}/layout/${encodeURIComponent(schema)}`,
99
106
  {
100
107
  method: 'PUT',
108
+ query: written(),
101
109
  body: { positions },
102
110
  timeout: REQUEST_TIMEOUT_MS,
103
111
  },
@@ -107,6 +115,7 @@ export function useDiagramPersistence() {
107
115
  async function createNote(payload: DiagramNoteCreate): Promise<DiagramNote> {
108
116
  return $authFetch<DiagramNote>(`${BASE}/notes`, {
109
117
  method: 'POST',
118
+ query: written(),
110
119
  body: payload,
111
120
  timeout: REQUEST_TIMEOUT_MS,
112
121
  })
@@ -118,6 +127,7 @@ export function useDiagramPersistence() {
118
127
  ): Promise<DiagramNote> {
119
128
  return $authFetch<DiagramNote>(`${BASE}/notes/${encodeURIComponent(id)}`, {
120
129
  method: 'PUT',
130
+ query: written(),
121
131
  body: patch,
122
132
  timeout: REQUEST_TIMEOUT_MS,
123
133
  })
@@ -126,7 +136,7 @@ export function useDiagramPersistence() {
126
136
  async function deleteNote(id: string): Promise<void> {
127
137
  await $authFetch<{ success: boolean }>(
128
138
  `${BASE}/notes/${encodeURIComponent(id)}`,
129
- { method: 'DELETE', timeout: REQUEST_TIMEOUT_MS },
139
+ { method: 'DELETE', query: written(), timeout: REQUEST_TIMEOUT_MS },
130
140
  )
131
141
  }
132
142
 
@@ -10,7 +10,6 @@ const LOCKABLE_PAGES: ReadonlyArray<{
10
10
  path: string
11
11
  feature: ConnectionFeature
12
12
  }> = [
13
- { path: '/modules/database/diagram', feature: 'diagram' },
14
13
  { path: '/modules/database/query', feature: 'queryConsole' },
15
14
  ]
16
15
 
@@ -10,15 +10,10 @@ export interface ColumnsResponse {
10
10
  primaryKey: string | null
11
11
  }
12
12
 
13
- /** The rows a search or a column filter reads on an external database. */
14
- export const EXTERNAL_SCAN_CAP = 10_000
15
-
16
13
  export interface ListResponse {
17
14
  results: Record<string, unknown>[]
18
15
  total: number
19
16
  primaryKey: string | null
20
- /** The rows or the total cover only part of an external table. */
21
- capped: boolean
22
17
  }
23
18
 
24
19
  /**
@@ -51,7 +46,6 @@ export function gridDataOf(
51
46
  rows: list.results ?? [],
52
47
  total: list.total ?? 0,
53
48
  primaryKey,
54
- capped: list.capped ?? false,
55
49
  }
56
50
  }
57
51
 
@@ -668,8 +668,6 @@ useEventListener('keydown', (event: KeyboardEvent) => {
668
668
  v-model:page="state.page"
669
669
  v-model:page-size="state.pageSize"
670
670
  :total="total"
671
- :capped="data?.capped"
672
- :refined="hasRefinements"
673
671
  />
674
672
  </div>
675
673
  </template>
@@ -1,18 +1,12 @@
1
1
  <script setup lang="ts">
2
- import FeatureLocked from '../build/components/FeatureLocked.vue'
3
2
  import SchemaDiagramBoard from '../build/components/SchemaDiagramBoard.vue'
4
3
  import { useDatabaseConnections } from '../build/composables/useDatabaseConnections'
5
4
 
6
- const { t } = useI18n()
7
- const { lacks, ready } = useDatabaseConnections()
5
+ const { ready } = useDatabaseConnections()
8
6
 
9
7
  await ready
10
8
  </script>
11
9
 
12
10
  <template>
13
- <FeatureLocked
14
- v-if="lacks('diagram')"
15
- :title="t('dms_database.diagram.title')"
16
- />
17
- <SchemaDiagramBoard v-else />
11
+ <SchemaDiagramBoard />
18
12
  </template>
@@ -373,7 +373,6 @@ async function copyName() {
373
373
  :label="t('dms_database.inspector.actions.query')"
374
374
  />
375
375
  <UButton
376
- v-if="!lacks('diagram')"
377
376
  :to="tableLink('diagram', address)"
378
377
  @click="emit('success')"
379
378
  icon="i-ph-graph"
@@ -152,8 +152,6 @@
152
152
  "close_keep": "Keep editing"
153
153
  },
154
154
  "grid": {
155
- "count_capped": "Counts stop at {count} rows",
156
- "capped": "Matches among the first {count} rows",
157
155
  "rows": "{count} row | {count} rows",
158
156
  "search": "Search rows",
159
157
  "refresh": "Refresh (R)",
@@ -319,6 +317,7 @@
319
317
  "schema": "Schema {schema} not found",
320
318
  "table": "Table {table} not found in {schema}"
321
319
  },
320
+ "references_failed": "The database did not report the references of {schema}: the diagram shows its tables without them.",
322
321
  "large": "{count} tables: select one and focus on it to read its relations.",
323
322
  "save": {
324
323
  "idle": "Layout saved",
@@ -152,8 +152,6 @@
152
152
  "close_keep": "Continuer"
153
153
  },
154
154
  "grid": {
155
- "count_capped": "Le décompte s’arrête à {count} lignes",
156
- "capped": "Correspondances parmi les {count} premières lignes",
157
155
  "rows": "{count} ligne | {count} lignes",
158
156
  "search": "Chercher dans les lignes",
159
157
  "refresh": "Actualiser (R)",
@@ -319,6 +317,7 @@
319
317
  "schema": "Schéma {schema} introuvable",
320
318
  "table": "Table {table} introuvable dans {schema}"
321
319
  },
320
+ "references_failed": "La base n'a pas indiqué les références de {schema} : le diagramme montre ses tables sans elles.",
322
321
  "large": "{count} tables : sélectionnez-en une et isolez-la pour lire ses relations.",
323
322
  "save": {
324
323
  "idle": "Disposition enregistrée",
@@ -323,15 +323,11 @@ describe('database switcher widget', () => {
323
323
  describe('database switcher: locked pages', () => {
324
324
  const lockedIds = () => menuLocks.value.map((entry) => entry.fullId).sort()
325
325
 
326
- it('locks the Diagram and Query console entries while an external database is selected, which a switcher leaving the sidebar open gets wrong', async () => {
326
+ it('locks the Query console entry and leaves the Diagram open while an external database is selected, which a switcher leaving the sidebar open gets wrong', async () => {
327
327
  await mountSwitcher(connectionsBackend(connectionsState(WAREHOUSE)))
328
- expect(lockedIds()).toEqual([
329
- 'page/modules/database/diagram',
330
- 'page/modules/database/query',
331
- ])
328
+ expect(lockedIds()).toEqual(['page/modules/database/query'])
332
329
  expect(menuLocks.value.map((entry) => entry.reason)).toEqual([
333
330
  '$dms_database.connections.locked.reason',
334
- '$dms_database.connections.locked.reason',
335
331
  ])
336
332
  })
337
333
 
@@ -0,0 +1,46 @@
1
+ import { expect, it } from 'vitest'
2
+ import { inBrowser, type BackendRead } from './fixtures/serverRender'
3
+ import { useDiagramPersistence } from '../app/build/composables/useDiagramPersistence'
4
+
5
+ const NOTE = {
6
+ id: 'n1',
7
+ schemaName: 'public',
8
+ text: '',
9
+ x: 0,
10
+ y: 0,
11
+ width: 200,
12
+ height: 100,
13
+ color: null,
14
+ createdAt: '2026-10-01T10:00:00.000Z',
15
+ updatedAt: '2026-10-01T10:00:00.000Z',
16
+ }
17
+
18
+ function backend({ method }: BackendRead): unknown {
19
+ return method === 'DELETE' || method === 'GET' ? { success: true } : NOTE
20
+ }
21
+
22
+ it('names the database the page loaded with on every diagram write, which a server checking the selection alone would let a stale tab misfile', async () => {
23
+ const browser = inBrowser(
24
+ () => useDiagramPersistence(() => 'warehouse'),
25
+ backend,
26
+ )
27
+ await browser.value.saveLayout('public', { orders: { x: 1, y: 2 } })
28
+ await browser.value.createNote({
29
+ schemaName: 'public',
30
+ text: '',
31
+ x: 0,
32
+ y: 0,
33
+ width: 200,
34
+ height: 100,
35
+ })
36
+ await browser.value.updateNote('n1', { x: 5 })
37
+ await browser.value.deleteNote('n1')
38
+ expect(
39
+ browser.reads.map(({ method, url, query }) => [method, url, query]),
40
+ ).toEqual([
41
+ ['PUT', '/api/database/diagram/layout/public', { connection: 'warehouse' }],
42
+ ['POST', '/api/database/diagram/notes', { connection: 'warehouse' }],
43
+ ['PUT', '/api/database/diagram/notes/n1', { connection: 'warehouse' }],
44
+ ['DELETE', '/api/database/diagram/notes/n1', { connection: 'warehouse' }],
45
+ ])
46
+ })
@@ -217,53 +217,6 @@ describe('a read-only external database in the data grid', () => {
217
217
  })
218
218
  })
219
219
 
220
- describe('a capped page of an external database in the data grid', () => {
221
- async function gridText(capped: boolean, search = '') {
222
- const page = browserMount(
223
- DataGrid,
224
- connectionsBackend(connectionsState(WAREHOUSE), {
225
- others: (read) =>
226
- read.url === '/api/database/browse/list'
227
- ? { results: [{ _id: '1' }], total: 1, primaryKey: '_id', capped }
228
- : others(read),
229
- }),
230
- { tab: TAB },
231
- )
232
- await page.shown
233
- await vi.waitFor(() =>
234
- expect(page.text()).toContain('dms_database.data.grid.rows 1'),
235
- )
236
- if (search) {
237
- const input = page.find(
238
- (props) => props.placeholder === 'dms_database.data.grid.search',
239
- )?.['onUpdate:modelValue']
240
- if (typeof input === 'function') input(search)
241
- await vi.waitFor(
242
- () =>
243
- expect(page.reads.map((read) => read.query.search)).toContain(search),
244
- { timeout: 2000 },
245
- )
246
- }
247
- return page.text()
248
- }
249
-
250
- it('says a search matches among the first rows only, which a grid that drops the API cap gets wrong', async () => {
251
- expect(await gridText(true, 'retail')).toContain(
252
- 'dms_database.data.grid.capped 10000',
253
- )
254
- })
255
-
256
- it('says the count stops at the cap on a page with no search, where nothing is matched', async () => {
257
- const text = await gridText(true)
258
- expect(text).toContain('dms_database.data.grid.count_capped 10000')
259
- expect(text).not.toContain('dms_database.data.grid.capped')
260
- })
261
-
262
- it('says nothing of a cap on a page that read every row', async () => {
263
- expect(await gridText(false)).not.toMatch(/grid\.(count_)?capped/)
264
- })
265
- })
266
-
267
220
  const SAMPLE_POSITION = 'dms_database.inspector.sample.position'
268
221
 
269
222
  async function samplePosition(connection: DatabaseConnection) {
@@ -25,7 +25,7 @@ export const WAREHOUSE: DatabaseConnection = {
25
25
  engine: 'postgres',
26
26
  access: 'read',
27
27
  canWrite: true,
28
- unsupported: ['diagram', 'queryConsole', 'instances', 'rowReferences'],
28
+ unsupported: ['queryConsole', 'instances', 'rowReferences'],
29
29
  }
30
30
 
31
31
  /** The state the API answers while `selected` is browsed. */
@@ -1,4 +1,4 @@
1
- import { describe, expect, it } from 'vitest'
1
+ import { describe, expect, it, vi } from 'vitest'
2
2
  import { browserMount } from './fixtures/serverRender'
3
3
  import {
4
4
  CONNECTIONS_URL,
@@ -21,22 +21,42 @@ async function mount(
21
21
  return page
22
22
  }
23
23
 
24
- describe('diagram page on an external database', () => {
25
- it('shows the locked state with the lock icon and the reason, and reads nothing but the selection', async () => {
26
- const page = await mount(SchemaDiagram)
27
- expect(page.text()).toContain(LOCKED)
28
- expect(page.text()).toContain('icon="i-ph-lock"')
29
- expect(page.text()).toContain('dms_database.connections.locked.reason')
30
- expect(page.reads.map((read) => read.url)).toEqual([CONNECTIONS_URL])
31
- expect(page.errors).toEqual([])
32
- })
24
+ describe('diagram page', () => {
25
+ const SCHEMAS = {
26
+ schemas: [{ id: 'public', options: {}, tables: [], instances: [] }],
27
+ }
28
+ const REFERENCES_URL =
29
+ '/api/database/connections/warehouse/schemas/public/references'
33
30
 
34
- it('is locked by what the connection lists, not by being external', async () => {
35
- const page = await mount(
31
+ async function diagramReads(selected: typeof OWN) {
32
+ const page = browserMount(
36
33
  SchemaDiagram,
37
- connectionsState({ ...WAREHOUSE, unsupported: ['queryConsole'] }),
34
+ connectionsBackend(connectionsState(selected), {
35
+ others: (read) =>
36
+ read.url === '/api/database/schemas'
37
+ ? SCHEMAS
38
+ : read.url === REFERENCES_URL
39
+ ? { tables: {} }
40
+ : { positions: {}, items: [] },
41
+ }),
42
+ )
43
+ await page.shown
44
+ await vi.waitFor(() =>
45
+ expect(page.reads.map((read) => read.url)).toContain(
46
+ '/api/database/diagram/layout/public',
47
+ ),
38
48
  )
39
49
  expect(page.text()).not.toContain(LOCKED)
50
+ return page.reads.map((read) => read.url)
51
+ }
52
+
53
+ it('opens on an external database and reads the references its catalog reports', async () => {
54
+ expect(await diagramReads(WAREHOUSE)).toContain(REFERENCES_URL)
55
+ })
56
+
57
+ it('reads no catalog on the project database, whose schema declares its relations', async () => {
58
+ const urls = await diagramReads(OWN)
59
+ expect(urls.filter((url) => url.endsWith('/references'))).toEqual([])
40
60
  })
41
61
  })
42
62
 
@@ -50,10 +70,10 @@ describe('query console page on an external database', () => {
50
70
  expect(page.errors).toEqual([])
51
71
  })
52
72
 
53
- it('stays open when only the diagram is listed as unsupported', async () => {
73
+ it('stays open when only the instances are listed as unsupported', async () => {
54
74
  const page = await mount(
55
75
  QueryConsole,
56
- connectionsState({ ...WAREHOUSE, unsupported: ['diagram'] }),
76
+ connectionsState({ ...WAREHOUSE, unsupported: ['instances'] }),
57
77
  )
58
78
  expect(page.text()).not.toContain(LOCKED)
59
79
  expect(page.reads.map((read) => read.url)).toContain(
@@ -43,7 +43,7 @@ function backend({ url }: BackendRead): unknown {
43
43
  describe('reads on demand', () => {
44
44
  it("the diagram reads a schema's layout and notes when the canvas asks, each time", async () => {
45
45
  layoutVersion = 0
46
- const browser = inBrowser(useDiagramPersistence, backend)
46
+ const browser = inBrowser(() => useDiagramPersistence(() => 'own'), backend)
47
47
  expect(browser.reads).toEqual([])
48
48
  const first = await browser.value.readDiagram('shop')
49
49
  expect(first).toEqual({
@@ -62,7 +62,7 @@ describe('reads on demand', () => {
62
62
  })
63
63
 
64
64
  it('the diagram says so when its layout cannot be read', async () => {
65
- const browser = inBrowser(useDiagramPersistence, backend)
65
+ const browser = inBrowser(() => useDiagramPersistence(() => 'own'), backend)
66
66
  await expect(browser.value.readDiagram('broken')).rejects.toMatchObject({
67
67
  statusCode: 503,
68
68
  })
@@ -250,7 +250,7 @@ describe('server render: every read is handed to the browser', () => {
250
250
  expect(menuLocks.value).toEqual([])
251
251
  })
252
252
 
253
- it('table inspector on an external database: offers neither the query console nor the diagram, which an inspector linking to locked pages would not', async () => {
253
+ it('table inspector on an external database: offers the diagram and not the query console, which an inspector linking to a locked page would not', async () => {
254
254
  const external = connectionsState(WAREHOUSE)
255
255
  const page = await serverRender(
256
256
  TableInspector,
@@ -264,7 +264,7 @@ describe('server render: every read is handed to the browser', () => {
264
264
  expect(page.untransferred).toEqual([])
265
265
  expect(page.html).toContain('dms_database.inspector.actions.browse')
266
266
  expect(page.html).not.toContain('dms_database.inspector.actions.query')
267
- expect(page.html).not.toContain('dms_database.inspector.actions.diagram')
267
+ expect(page.html).toContain('dms_database.inspector.actions.diagram')
268
268
  })
269
269
 
270
270
  it('table inspector: counts instances on the project database only, which an inspector reading 1 instance on an external database gets wrong', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-database",
3
- "version": "0.5.5",
3
+ "version": "0.5.6-next.188.g9710e2a",
4
4
  "description": "Database console for the AntelopeJS DMS: schemas, relation diagrams, a data browser and an AQL query console.",
5
5
  "keywords": [
6
6
  "admin",
@@ -90,7 +90,7 @@
90
90
  ]
91
91
  },
92
92
  "dmsFrontend": "dist/frontend-module.js",
93
- "gitHead": "1149d6c7f195d645cf52e9cf7525a0ffeed9a0e2",
93
+ "gitHead": "9710e2aab1070dced8616e299397b38e5620602e",
94
94
  "scripts": {
95
95
  "build": "rimraf dist && tsc",
96
96
  "dev:frontend": "pnpm frontend:dev",