@antelopejs/dms-database 0.4.1 → 0.4.3

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 (33) hide show
  1. package/README.md +34 -11
  2. package/dist/service/browse.js +34 -5
  3. package/dist/service/browse.js.map +1 -1
  4. package/dist/service/declaredFields.d.ts +14 -0
  5. package/dist/service/declaredFields.js +106 -0
  6. package/dist/service/declaredFields.js.map +1 -0
  7. package/dist/service/introspect.js +19 -75
  8. package/dist/service/introspect.js.map +1 -1
  9. package/dist/service/queryInspection.js +1 -1
  10. package/dist/service/queryInspection.js.map +1 -1
  11. package/frontend-vue/app/build/diagram/graphModel.ts +4 -5
  12. package/frontend-vue/app/build/diagram/layout.ts +8 -7
  13. package/frontend-vue/app/build/diagram/packing.ts +0 -24
  14. package/frontend-vue/app/build/utils/fieldTypes.ts +18 -4
  15. package/frontend-vue/app/components/ConnectionStatus.vue +1 -1
  16. package/frontend-vue/app/components/DiagramTableNode.vue +2 -4
  17. package/frontend-vue/app/components/JsonCellPanel.vue +3 -1
  18. package/frontend-vue/app/components/QueryConsole.vue +11 -64
  19. package/frontend-vue/app/components/QueryResultPanel.vue +2 -17
  20. package/frontend-vue/app/components/SchemaDiagram.vue +12 -4
  21. package/frontend-vue/app/components/TableInspector.vue +2 -2
  22. package/frontend-vue/i18n/locales/database-en-GB.json +1 -4
  23. package/frontend-vue/i18n/locales/database-fr-FR.json +1 -4
  24. package/frontend-vue/package.json +1 -1
  25. package/frontend-vue/pnpm-lock.yaml +5 -5
  26. package/frontend-vue/tests/connectionStatus.test.ts +36 -0
  27. package/frontend-vue/tests/dataBrowser.test.ts +31 -1
  28. package/frontend-vue/tests/diagramLayout.test.ts +75 -41
  29. package/frontend-vue/tests/queryResultPanel.test.ts +38 -0
  30. package/frontend-vue/tests/serverRender.test.ts +31 -1
  31. package/frontend-vue/vitest.config.ts +9 -1
  32. package/package.json +7 -7
  33. package/skills/dms-database/SKILL.md +1 -1
@@ -23,14 +23,13 @@ import {
23
23
  overlaps,
24
24
  PACK_GAP,
25
25
  packBlocks,
26
- prefixOrder,
27
26
  type Rect,
28
27
  shelfRows,
29
28
  startViewport,
30
29
  } from '../app/build/diagram/packing'
31
30
 
32
31
  // A schema shaped like a real MongoDB one: about forty tables on their own,
33
- // most named `<module>__<table>`, a few groups linked by relations, a
32
+ // most named `<module>_<table>`, a few groups linked by relations, a
34
33
  // relation to another schema, and one very tall table (60 columns) whose
35
34
  // relation column and the column pointed at sit far below the fold.
36
35
 
@@ -56,13 +55,13 @@ function to(fromField: string, toTable: string, toField = '_id'): Relation {
56
55
 
57
56
  const ISOLATED = [
58
57
  ...Array.from({ length: 12 }, (_, i) =>
59
- table(`dms-core__t${String(i).padStart(2, '0')}`, 3 + (i % 6)),
58
+ table(`dms-core_t${String(i).padStart(2, '0')}`, 3 + (i % 6)),
60
59
  ),
61
60
  ...Array.from({ length: 10 }, (_, i) =>
62
- table(`dms-tenant__t${String(i).padStart(2, '0')}`, 4 + (i % 5)),
61
+ table(`dms-tenant_t${String(i).padStart(2, '0')}`, 4 + (i % 5)),
63
62
  ),
64
63
  ...Array.from({ length: 8 }, (_, i) =>
65
- table(`dms-files__t${String(i).padStart(2, '0')}`, 2 + (i % 7)),
64
+ table(`dms-files_t${String(i).padStart(2, '0')}`, 2 + (i % 7)),
66
65
  ),
67
66
  ...Array.from({ length: 10 }, (_, i) =>
68
67
  table(`plain_${String(i).padStart(2, '0')}`, 5 + (i % 4)),
@@ -71,28 +70,28 @@ const ISOLATED = [
71
70
 
72
71
  // audit (60 columns) -> users by `user_id`, its 46th column; sessions point
73
72
  // at audit's `code`, its 31st column.
74
- const audit = table('dms-core__audit', 60)
73
+ const audit = table('dms-core_audit', 60)
75
74
  audit.fields.user_id = { kind: 'string' }
76
- audit.relations = [to('user_id', 'dms-core__users')]
75
+ audit.relations = [to('user_id', 'dms-core_users')]
77
76
 
78
77
  const APP = {
79
78
  id: 'app',
80
79
  tables: [
81
80
  ...ISOLATED,
82
81
  audit,
83
- table('dms-core__users', 6),
84
- table('dms-core__sessions', 4, [
85
- to('audit_code', 'dms-core__audit', 'field_30'),
82
+ table('dms-core_users', 6),
83
+ table('dms-core_sessions', 4, [
84
+ to('audit_code', 'dms-core_audit', 'field_30'),
86
85
  ]),
87
- table('shop__orders', 5, [to('customer_id', 'shop__customers')]),
88
- table('shop__customers', 4),
89
- table('shop__items', 4, [
90
- to('order_id', 'shop__orders'),
91
- to('product_id', 'shop__products'),
86
+ table('shop_orders', 5, [to('customer_id', 'shop_customers')]),
87
+ table('shop_customers', 4),
88
+ table('shop_items', 4, [
89
+ to('order_id', 'shop_orders'),
90
+ to('product_id', 'shop_products'),
92
91
  ]),
93
- table('shop__products', 6),
94
- table('blog__posts', 5, [to('author_id', 'blog__authors')]),
95
- table('blog__authors', 3),
92
+ table('shop_products', 6),
93
+ table('blog_posts', 5, [to('author_id', 'blog_authors')]),
94
+ table('blog_authors', 3),
96
95
  table('invoices', 4, [
97
96
  {
98
97
  fromField: 'account_id',
@@ -142,9 +141,9 @@ function input(overrides: Partial<GraphInput> = {}): GraphInput {
142
141
  }
143
142
 
144
143
  const GROUPS = {
145
- core: ['dms-core__audit', 'dms-core__users', 'dms-core__sessions'],
146
- shop: ['shop__orders', 'shop__customers', 'shop__items', 'shop__products'],
147
- blog: ['blog__posts', 'blog__authors'],
144
+ core: ['dms-core_audit', 'dms-core_users', 'dms-core_sessions'],
145
+ shop: ['shop_orders', 'shop_customers', 'shop_items', 'shop_products'],
146
+ blog: ['blog_posts', 'blog_authors'],
148
147
  }
149
148
 
150
149
  describe('diagram layout', () => {
@@ -191,14 +190,14 @@ describe('diagram layout', () => {
191
190
  })
192
191
 
193
192
  it('runs dagre left to right within a group', () => {
194
- const items = placed.get('shop__items') as Rect
195
- const orders = placed.get('shop__orders') as Rect
196
- const customers = placed.get('shop__customers') as Rect
193
+ const items = placed.get('shop_items') as Rect
194
+ const orders = placed.get('shop_orders') as Rect
195
+ const customers = placed.get('shop_customers') as Rect
197
196
  expect(items.x).toBeLessThan(orders.x)
198
197
  expect(orders.x).toBeLessThan(customers.x)
199
198
  })
200
199
 
201
- it('places the groups first, then the tables on their own by prefix and name', () => {
200
+ it('places the groups first, then the tables on their own by name', () => {
202
201
  // Rows are bands no table crosses: merge the tables' heights.
203
202
  const bands: [number, number][] = []
204
203
  for (const rect of [...placed.values()].sort((a, b) => a.y - b.y)) {
@@ -214,7 +213,7 @@ describe('diagram layout', () => {
214
213
  }
215
214
  const linked = Object.values(GROUPS).flat()
216
215
  const lastGroupRow = Math.max(...linked.map(rowOf))
217
- const order = prefixOrder(ISOLATED.map((t) => t.name))
216
+ const order = ISOLATED.map((t) => t.name).sort((a, b) => a.localeCompare(b))
218
217
  // Rows follow the order: a table never sits on a row above one before it.
219
218
  for (let i = 1; i < order.length; i++)
220
219
  expect(rowOf(order[i] as string)).toBeGreaterThanOrEqual(
@@ -227,12 +226,6 @@ describe('diagram layout', () => {
227
226
  expect(lastGroupRow).toBeLessThanOrEqual(rowOf(order.at(-1) as string))
228
227
  })
229
228
 
230
- it('orders by prefix, the tables without one last, then by name', () => {
231
- expect(
232
- prefixOrder(['plain', 'b__x', 'a__z', 'a__y', 'aa', 'b__a']),
233
- ).toEqual(['a__y', 'a__z', 'b__a', 'b__x', 'aa', 'plain'])
234
- })
235
-
236
229
  it('keeps clear of the notes', () => {
237
230
  const note = { x: 300, y: 0, width: 220, height: 140 }
238
231
  const around = rects(APP, layOutSchema(APP, { obstacles: [note] }))
@@ -286,10 +279,10 @@ describe('diagram layout', () => {
286
279
 
287
280
  describe('folded tables', () => {
288
281
  it('shows the first columns and every column an arrow ends on', () => {
289
- const shown = shownColumns(APP, tableOf('dms-core__audit'), false)
282
+ const shown = shownColumns(APP, tableOf('dms-core_audit'), false)
290
283
  expect(shown.foldable).toBe(true)
291
284
  expect(shown.columns.slice(0, FOLDED_COLUMNS)).toEqual(
292
- Object.keys(tableOf('dms-core__audit').fields).slice(0, FOLDED_COLUMNS),
285
+ Object.keys(tableOf('dms-core_audit').fields).slice(0, FOLDED_COLUMNS),
293
286
  )
294
287
  // Its key, its relation column, and the column sessions point at.
295
288
  expect(shown.columns).toContain('_id')
@@ -297,19 +290,19 @@ describe('folded tables', () => {
297
290
  expect(shown.columns).toContain('field_30')
298
291
  expect(shown.columns).toHaveLength(FOLDED_COLUMNS + 2)
299
292
  expect(shown.hiddenCount).toBe(61 - FOLDED_COLUMNS - 2)
300
- const open = shownColumns(APP, tableOf('dms-core__audit'), true)
293
+ const open = shownColumns(APP, tableOf('dms-core_audit'), true)
301
294
  expect(open.columns).toHaveLength(61)
302
295
  expect(open.hiddenCount).toBe(0)
303
296
  })
304
297
 
305
298
  it('leaves small tables as they are, with no fold row', () => {
306
- const shown = shownColumns(APP, tableOf('shop__orders'), false)
299
+ const shown = shownColumns(APP, tableOf('shop_orders'), false)
307
300
  expect(shown).toMatchObject({ foldable: false, hiddenCount: 0 })
308
- expect(nodeHeight(APP, tableOf('shop__orders'))).toBe(44 + 6 * 24)
301
+ expect(nodeHeight(APP, tableOf('shop_orders'))).toBe(44 + 6 * 24)
309
302
  })
310
303
 
311
304
  it('lays out at the folded height', () => {
312
- const audit = tableOf('dms-core__audit')
305
+ const audit = tableOf('dms-core_audit')
313
306
  expect(nodeHeight(APP, audit)).toBe(44 + (FOLDED_COLUMNS + 2 + 1) * 24)
314
307
  expect(nodeHeight(APP, audit, true)).toBe(44 + (61 + 1) * 24)
315
308
  })
@@ -330,10 +323,51 @@ describe('folded tables', () => {
330
323
  }
331
324
  })
332
325
 
326
+ it('ends an arrow on the table when its column is named like an Object member and absent', () => {
327
+ const relation = (fromField: string, toField: string) => ({
328
+ fromField,
329
+ toSchema: 'quirks',
330
+ toTable: 'teams',
331
+ toField,
332
+ many: false,
333
+ })
334
+ const schema: SchemaSummary = {
335
+ ...APP,
336
+ id: 'quirks',
337
+ tables: [
338
+ {
339
+ name: 'members',
340
+ fields: { _id: { kind: 'string' }, team: { kind: 'string' } },
341
+ indexes: {},
342
+ relations: [
343
+ relation('team', 'constructor'),
344
+ relation('toString', '_id'),
345
+ ],
346
+ },
347
+ {
348
+ name: 'teams',
349
+ fields: { _id: { kind: 'string' } },
350
+ indexes: {},
351
+ relations: [],
352
+ },
353
+ ],
354
+ }
355
+ const graph = buildGraph(input({ schema }))
356
+ expect(
357
+ graph.edges.map((edge) => [
358
+ edge.sourceHandle.split('::')[0],
359
+ edge.targetHandle.split('::')[0],
360
+ ]),
361
+ ).toEqual([
362
+ ['team', '__node__'],
363
+ ['__node__', '_id'],
364
+ ])
365
+ })
366
+
333
367
  it('draws an expanded table whole, above the others', () => {
334
- const graph = buildGraph(input({ expanded: new Set(['dms-core__audit']) }))
368
+ const graph = buildGraph(input({ expanded: new Set(['dms-core_audit']) }))
335
369
  const node = graph.nodes.find(
336
- (n) => n.id === tableNodeId('app', 'dms-core__audit'),
370
+ (n) => n.id === tableNodeId('app', 'dms-core_audit'),
337
371
  )
338
372
  const data = node?.data as unknown as TableNodeData
339
373
  expect(data.columns).toHaveLength(61)
@@ -343,7 +377,7 @@ describe('folded tables', () => {
343
377
 
344
378
  it('unfolds the table a search finds a folded column in', () => {
345
379
  const none = new Set<string>()
346
- const audit = 'dms-core__audit'
380
+ const audit = 'dms-core_audit'
347
381
  expect(expandForSearch(APP, audit, 'field_40', none)).toEqual(
348
382
  new Set([audit]),
349
383
  )
@@ -0,0 +1,38 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { serverRender } from './fixtures/serverRender'
3
+ import QueryResultPanel from '../app/components/QueryResultPanel.vue'
4
+
5
+ const SERVER_CAP = 1000
6
+
7
+ const result = (count: number) => ({
8
+ rows: Array.from({ length: count }, (_, index) => ({
9
+ _id: `reading-${index}`,
10
+ value: index,
11
+ })),
12
+ rowCount: count,
13
+ truncated: false,
14
+ mutation: false,
15
+ executedAt: '2026-11-08T10:00:00.000Z',
16
+ durationMs: 12,
17
+ })
18
+
19
+ const renderResult = (count: number) =>
20
+ serverRender(
21
+ QueryResultPanel,
22
+ {
23
+ result: result(count),
24
+ failure: null,
25
+ target: { schema: 'metrics', table: 'readings', instance: '' },
26
+ schemas: [],
27
+ },
28
+ { url: '/modules/database/query', respond: () => ({}) },
29
+ )
30
+
31
+ describe('query result table', () => {
32
+ it('shows every row the server returns, up to its 1,000-row cap', async () => {
33
+ const { html } = await renderResult(SERVER_CAP)
34
+ expect(html).toContain('reading-0<')
35
+ expect(html).toContain(`reading-${SERVER_CAP - 1}<`)
36
+ expect(html).toContain(`dms_database.query.result.all_shown ${SERVER_CAP}`)
37
+ })
38
+ })
@@ -145,7 +145,14 @@ describe('server render: every read is handed to the browser', () => {
145
145
 
146
146
  const grid = await render(
147
147
  DataGrid,
148
- { tab: { id: 'shop.orders', schema: 'shop', instance: '', table: 'orders' } },
148
+ {
149
+ tab: {
150
+ id: 'shop.orders',
151
+ schema: 'shop',
152
+ instance: '',
153
+ table: 'orders',
154
+ },
155
+ },
149
156
  '/modules/database/data?schema=shop&table=orders',
150
157
  )
151
158
  const scroller = grid.html
@@ -252,6 +259,29 @@ describe('server render: every read is handed to the browser', () => {
252
259
  expect(page.html).toContain('dms_database.inspector.cols.not_nullable')
253
260
  })
254
261
 
262
+ it('table inspector: a column named like an Object member is listed like any other', async () => {
263
+ const members = {
264
+ name: 'members',
265
+ fields: { _id: { kind: 'string' }, constructor: { kind: 'string' } },
266
+ indexes: {},
267
+ relations: [],
268
+ modifiers: {},
269
+ }
270
+ const page = await serverRender(
271
+ TableInspector,
272
+ { rowData: { schema: 'quirks', name: 'members' } },
273
+ {
274
+ url: '/modules/database/schemas',
275
+ respond: (read) =>
276
+ read.url === '/api/database/schemas'
277
+ ? { schemas: [{ ...schema('quirks'), tables: [members] }] }
278
+ : backend(read),
279
+ },
280
+ )
281
+ expect(page.html).toMatch(/>\s*constructor\s*</)
282
+ expect(page.html).toContain('i-ph-text-aa')
283
+ })
284
+
255
285
  it('schemas filter bar: the tables listed out of all', async () => {
256
286
  const page = await render(
257
287
  SchemasFilterBar,
@@ -8,6 +8,10 @@ import { backendBoundary } from './build/backend-boundary.ts'
8
8
  // `@antelopejs/dms`), as `pnpm test:frontend` builds against them.
9
9
  const root = resolve(__dirname, '..', 'node_modules', '@antelopejs')
10
10
 
11
+ /** Matches one test file wherever the checkout lives, dot directories included. */
12
+ const testFile = (name: string) =>
13
+ resolve(__dirname, 'tests', name).replace(/[\\*?[\]{}()!+@|]/g, '\\$&')
14
+
11
15
  export default defineConfig({
12
16
  plugins: [vue(), backendBoundary()],
13
17
  resolve: {
@@ -33,7 +37,11 @@ export default defineConfig({
33
37
  // `render`, not the server's `ssrRender`): what a client navigation
34
38
  // mounts.
35
39
  testTransformMode: {
36
- web: ['**/clientNavigation.test.ts', '**/apiErrorPresentation.test.ts'],
40
+ web: [
41
+ testFile('clientNavigation.test.ts'),
42
+ testFile('apiErrorPresentation.test.ts'),
43
+ testFile('connectionStatus.test.ts'),
44
+ ],
37
45
  },
38
46
  },
39
47
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-database",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
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",
@@ -70,17 +70,17 @@
70
70
  "@antelopejs/interface-api": ">=0.3.0 <1.0.0",
71
71
  "@antelopejs/interface-api-util": ">=0.3.0 <1.0.0",
72
72
  "@antelopejs/interface-core": ">=0.4.0 <1.0.0",
73
- "@antelopejs/interface-database": ">=0.3.0 <1.0.0",
74
- "@antelopejs/interface-database-decorators": ">=0.2.0 <1.0.0",
73
+ "@antelopejs/interface-database": ">=0.3.1 <1.0.0",
74
+ "@antelopejs/interface-database-decorators": ">=0.2.1 <1.0.0",
75
75
  "@antelopejs/interface-dms": ">=0.12.0 <1.0.0"
76
76
  },
77
77
  "devDependencies": {
78
- "@antelopejs/core": "^1.20.0",
79
- "@antelopejs/dms": ">=0.16.1 <1.0.0",
78
+ "@antelopejs/core": "^1.21.0",
79
+ "@antelopejs/dms": ">=0.17.0 <1.0.0",
80
80
  "@antelopejs/dms-frontend": ">=0.10.0 <0.11.0",
81
81
  "@antelopejs/interface-data-api": ">=0.6.1 <1.0.0",
82
82
  "@antelopejs/mongodb": "^1.6.2",
83
- "@antelopejs/tooling-configs": "^0.2.18",
83
+ "@antelopejs/tooling-configs": "^0.3.3",
84
84
  "@types/chai": "^5.2.3",
85
85
  "@types/mocha": "^10.0.10",
86
86
  "@types/node": "^24.0.0",
@@ -99,7 +99,7 @@
99
99
  "typescript": "^6.0.3"
100
100
  },
101
101
  "optionalDependencies": {
102
- "@antelopejs/interface-dms-automation": ">=0.6.0 <1.0.0"
102
+ "@antelopejs/interface-dms-automation": ">=0.6.1 <1.0.0"
103
103
  },
104
104
  "packageManager": "pnpm@10.33.0",
105
105
  "antelopeJs": {
@@ -32,5 +32,5 @@ A read-mostly database console for the platform owner. It has no API for other m
32
32
  - Owner-only: pages and `/api/database/*` routes answer the platform owner alone.
33
33
  - The data browser is read-only on **All instances**; a saved edit can be undone for 10 seconds only.
34
34
  - Write queries in the console always run a dry run and need the table name typed to confirm.
35
- - Diagram: a table with more than 12 columns is drawn folded (key and relation columns stay visible); folding is per viewer, not saved. Auto layout keeps related tables together and sets the others in rows by `<prefix>__` name; it overwrites the team's saved layout once kept.
35
+ - Diagram: a table with more than 12 columns is drawn folded (key and relation columns stay visible); folding is per viewer, not saved. Auto layout keeps related tables together and sets the others in rows by name; it overwrites the team's saved layout once kept.
36
36
  - `table-watch` needs a change feed: MongoDB must run as a replica set.