@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
@@ -3,6 +3,7 @@ import { defineComponent, h } from 'vue'
3
3
  import { serverRender, type BackendRead } from './fixtures/serverRender'
4
4
  import ConnectionStatus from '../app/components/ConnectionStatus.vue'
5
5
  import DataBrowser from '../app/components/DataBrowser.vue'
6
+ import DataGrid from '../app/components/DataGrid.vue'
6
7
  import QueryConsole from '../app/components/QueryConsole.vue'
7
8
  import SchemaDiagram from '../app/components/SchemaDiagram.vue'
8
9
  import SchemasFilterBar from '../app/components/SchemasFilterBar.vue'
@@ -14,7 +15,10 @@ import TableInspector from '../app/components/TableInspector.vue'
14
15
 
15
16
  const table = (name: string) => ({
16
17
  name,
17
- fields: { _id: { kind: 'string' } },
18
+ fields: {
19
+ _id: { kind: 'string' },
20
+ note: { kind: 'union', members: [{ kind: 'string' }, { kind: 'null' }] },
21
+ },
18
22
  indexes: {},
19
23
  relations: [],
20
24
  })
@@ -119,6 +123,38 @@ describe('server render: every read is handed to the browser', () => {
119
123
  expect(page.html).toContain('>7<')
120
124
  })
121
125
 
126
+ it('data browser: the table list stacks above the grid below md', async () => {
127
+ const page = await render(DataBrowser, {}, '/modules/database/data')
128
+ const root = page.html.match(/^<div class="([^"]*)"/)?.[1]?.split(' ')
129
+ const aside = page.html.match(/<aside class="([^"]*)"/)?.[1]?.split(' ')
130
+ expect(root).toEqual(expect.arrayContaining(['flex-col', 'md:flex-row']))
131
+ expect(aside).toEqual(
132
+ expect.arrayContaining(['w-full', 'max-h-[40vh]', 'border-b']),
133
+ )
134
+ expect(aside).toEqual(
135
+ expect.arrayContaining(['md:w-[264px]', 'md:max-h-none', 'md:border-r']),
136
+ )
137
+ expect(aside).not.toContain('w-[264px]')
138
+ })
139
+
140
+ it('data browser: the stacked grid keeps a usable height below md', async () => {
141
+ const browser = await render(DataBrowser, {}, '/modules/database/data')
142
+ const root = browser.html.match(/^<div class="([^"]*)"/)?.[1]?.split(' ')
143
+ expect(root).toEqual(expect.arrayContaining(['min-h-fit', 'md:min-h-0']))
144
+ expect(root).not.toContain('min-h-0')
145
+
146
+ const grid = await render(
147
+ DataGrid,
148
+ { tab: { id: 'shop.orders', schema: 'shop', instance: '', table: 'orders' } },
149
+ '/modules/database/data?schema=shop&table=orders',
150
+ )
151
+ const scroller = grid.html
152
+ .match(/<div class="([^"]*scroll-pl-14[^"]*)"/)?.[1]
153
+ ?.split(' ')
154
+ expect(scroller).toEqual(expect.arrayContaining(['min-h-80', 'md:min-h-0']))
155
+ expect(scroller).not.toContain('min-h-0')
156
+ })
157
+
122
158
  it('query console: the library, saved, shared and run', async () => {
123
159
  const page = await render(QueryConsole, {}, '/modules/database/query')
124
160
  expect(page.reads.map((read) => read.url).sort()).toEqual([
@@ -170,6 +206,52 @@ describe('server render: every read is handed to the browser', () => {
170
206
  expect(page.html).toContain('9876')
171
207
  })
172
208
 
209
+ it('table inspector: leaves the position and steps to the DMS header', async () => {
210
+ const page = await render(
211
+ TableInspector,
212
+ {
213
+ rowData: { schema: 'shop', name: 'orders' },
214
+ navigation: {
215
+ index: 2,
216
+ total: 87,
217
+ hasPrev: true,
218
+ hasNext: true,
219
+ prev: () => {},
220
+ next: () => {},
221
+ },
222
+ },
223
+ '/modules/database/schemas',
224
+ )
225
+ expect(page.html).toContain('orders')
226
+ expect(page.html).not.toMatch(/3\s*\/\s*87/)
227
+ expect(page.html).not.toContain('i-ph-caret-up')
228
+ expect(page.html).not.toContain('i-ph-caret-down')
229
+ })
230
+
231
+ it('table inspector: the name in the header only, the columns at their width', async () => {
232
+ const page = await render(
233
+ TableInspector,
234
+ { rowData: { schema: 'shop', name: 'orders' } },
235
+ '/modules/database/schemas',
236
+ )
237
+ // The DMS header names the table: no heading of its own in the body.
238
+ expect(page.html).not.toMatch(/<h3[^>]*>\s*orders/)
239
+ // Narrower than its columns, the table scrolls sideways; the types
240
+ // and the tabs stay on one line.
241
+ expect(page.html).toMatch(
242
+ /data-columns-scroller[^>]*overflow-x-auto|overflow-x-auto[^>]*data-columns-scroller/,
243
+ )
244
+ expect(page.html).toContain('min-w-[30rem]')
245
+ expect(page.html).toContain('whitespace-nowrap')
246
+ expect(page.html).toContain('data-drawer-tabs')
247
+ // `string | null` reads `string`, with its icon; the Null column
248
+ // answers the same way for every column.
249
+ expect(page.html).not.toContain('string | null')
250
+ expect(page.html).not.toContain('border-dashed')
251
+ expect(page.html).toContain('dms_database.inspector.cols.nullable')
252
+ expect(page.html).toContain('dms_database.inspector.cols.not_nullable')
253
+ })
254
+
173
255
  it('schemas filter bar: the tables listed out of all', async () => {
174
256
  const page = await render(
175
257
  SchemasFilterBar,
@@ -25,5 +25,12 @@ export default defineConfig({
25
25
  'vue-i18n': resolve(__dirname, 'tests/fixtures/vueI18n.ts'),
26
26
  },
27
27
  },
28
- test: { environment: 'node', include: ['tests/**/*.test.ts'] },
28
+ test: {
29
+ environment: 'node',
30
+ include: ['tests/**/*.test.ts'],
31
+ // Still Node, but the components compiled for a browser (a client
32
+ // `render`, not the server's `ssrRender`): what a client navigation
33
+ // mounts.
34
+ testTransformMode: { web: ['**/clientNavigation.test.ts'] },
35
+ },
29
36
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-database",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
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",
@@ -62,14 +62,14 @@
62
62
  "@antelopejs/interface-api": ">=0.0.15 <1.0.0",
63
63
  "@antelopejs/interface-api-util": ">=0.1.3 <1.0.0",
64
64
  "@antelopejs/interface-core": ">=0.2.4 <1.0.0",
65
- "@antelopejs/interface-database": ">=0.1.10 <1.0.0",
66
- "@antelopejs/interface-database-decorators": ">=0.1.9 <1.0.0",
67
- "@antelopejs/interface-dms": ">=0.7.2 <1.0.0"
65
+ "@antelopejs/interface-database": ">=0.1.11 <1.0.0",
66
+ "@antelopejs/interface-database-decorators": ">=0.1.10 <1.0.0",
67
+ "@antelopejs/interface-dms": ">=0.9.0 <1.0.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@antelopejs/core": ">=1.16.0 <2",
71
- "@antelopejs/dms": ">=0.9.3 <1.0.0",
72
- "@antelopejs/dms-frontend": ">=0.6.3 <0.7.0",
70
+ "@antelopejs/core": ">=1.17.1 <2",
71
+ "@antelopejs/dms": ">=0.11.0 <1.0.0",
72
+ "@antelopejs/dms-frontend": ">=0.9.0 <0.10.0",
73
73
  "@antelopejs/tooling-configs": ">=0.0.9 <1.0.0",
74
74
  "@types/chai": "^5.2.3",
75
75
  "@types/mocha": "^10.0.10",
@@ -98,5 +98,6 @@
98
98
  "skills": [
99
99
  "./skills"
100
100
  ]
101
- }
101
+ },
102
+ "dmsFrontend": "dist/frontend-module.js"
102
103
  }
@@ -18,7 +18,7 @@ A read-mostly database console for the platform owner. It has no API for other m
18
18
 
19
19
  ## Config (`antelope.config.ts`, all optional)
20
20
 
21
- - Version 0.2+ needs `@antelopejs/dms` 0.9 (`interface-dms` 0.7) and `@antelopejs/dms-frontend` 0.6; 0.1 is the DMS 0.8 line.
21
+ - It needs `@antelopejs/dms` 0.11 (`interface-dms` 0.9) and `@antelopejs/dms-frontend` 0.9; 0.3 is the DMS 0.10 line.
22
22
 
23
23
  - `driverLabel: "MongoDB 8.0"`: the database name on the Overview (the interface cannot discover it).
24
24
  - `schemaLabels: { "<schemaId or glob*>": { label, color?: Tone } }`: badges; built-in patterns cover `app*`, `core*`, `global*`, `staging*`, `review*`, `prod*`.
@@ -32,4 +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
36
  - `table-watch` needs a change feed: MongoDB must run as a replica set.