@antelopejs/dms-database 0.4.4 → 0.5.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.
- package/README.md +12 -10
- package/dist/automation/tableWatch.d.ts +2 -2
- package/dist/automation/tableWatch.js +3 -3
- package/dist/automation/tableWatch.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -1
- package/dist/connectionAccess.d.ts +3 -0
- package/dist/connectionAccess.js +20 -0
- package/dist/connectionAccess.js.map +1 -0
- package/dist/db/models/connection_selections.model.d.ts +27 -0
- package/dist/db/models/connection_selections.model.js +17 -0
- package/dist/db/models/connection_selections.model.js.map +1 -0
- package/dist/db/models/diagram_layouts.model.d.ts +4 -4
- package/dist/db/models/diagram_layouts.model.js +14 -12
- package/dist/db/models/diagram_layouts.model.js.map +1 -1
- package/dist/db/models/diagram_notes.model.d.ts +3 -3
- package/dist/db/models/index.d.ts +1 -0
- package/dist/db/models/index.js +1 -0
- package/dist/db/models/index.js.map +1 -1
- package/dist/db/models/query_history.model.d.ts +3 -3
- package/dist/db/models/saved_queries.model.d.ts +3 -3
- package/dist/db/tables/connection_selections.table.d.ts +6 -0
- package/dist/db/tables/connection_selections.table.js +30 -0
- package/dist/db/tables/connection_selections.table.js.map +1 -0
- package/dist/db/tables/index.d.ts +1 -0
- package/dist/db/tables/index.js +1 -0
- package/dist/db/tables/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/pages/externalLock.d.ts +8 -0
- package/dist/pages/externalLock.js +32 -0
- package/dist/pages/externalLock.js.map +1 -0
- package/dist/pages/overview.js +6 -3
- package/dist/pages/overview.js.map +1 -1
- package/dist/pages/schemas.js +6 -2
- package/dist/pages/schemas.js.map +1 -1
- package/dist/routes/connections.d.ts +14 -0
- package/dist/routes/connections.js +116 -0
- package/dist/routes/connections.js.map +1 -0
- package/dist/routes/data.d.ts +10 -9
- package/dist/routes/data.js +43 -62
- package/dist/routes/data.js.map +1 -1
- package/dist/routes/diagram.d.ts +6 -6
- package/dist/routes/diagram.js +16 -6
- package/dist/routes/diagram.js.map +1 -1
- package/dist/routes/health.d.ts +1 -1
- package/dist/routes/health.js +3 -2
- package/dist/routes/health.js.map +1 -1
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/overview.d.ts +2 -2
- package/dist/routes/overview.js +11 -4
- package/dist/routes/overview.js.map +1 -1
- package/dist/routes/query.d.ts +1 -1
- package/dist/routes/query.js +26 -10
- package/dist/routes/query.js.map +1 -1
- package/dist/routes/schemas.d.ts +1 -1
- package/dist/routes/schemas.js +4 -2
- package/dist/routes/schemas.js.map +1 -1
- package/dist/routes/tables.d.ts +2 -1
- package/dist/routes/tables.js +29 -21
- package/dist/routes/tables.js.map +1 -1
- package/dist/service/browse.d.ts +14 -6
- package/dist/service/browse.js +120 -18
- package/dist/service/browse.js.map +1 -1
- package/dist/service/catalog.js +2 -1
- package/dist/service/catalog.js.map +1 -1
- package/dist/service/connectionState.d.ts +29 -0
- package/dist/service/connectionState.js +157 -0
- package/dist/service/connectionState.js.map +1 -0
- package/dist/service/connections.d.ts +12 -0
- package/dist/service/connections.js +72 -0
- package/dist/service/connections.js.map +1 -0
- package/dist/service/database.d.ts +12 -0
- package/dist/service/database.js +30 -0
- package/dist/service/database.js.map +1 -0
- package/dist/service/declaredFields.d.ts +3 -2
- package/dist/service/declaredFields.js +6 -7
- package/dist/service/declaredFields.js.map +1 -1
- package/dist/service/health.d.ts +2 -1
- package/dist/service/health.js +48 -21
- package/dist/service/health.js.map +1 -1
- package/dist/service/introspect.d.ts +7 -5
- package/dist/service/introspect.js +49 -41
- package/dist/service/introspect.js.map +1 -1
- package/dist/service/overview.d.ts +3 -2
- package/dist/service/overview.js +4 -4
- package/dist/service/overview.js.map +1 -1
- package/dist/service/queryInspection.js +6 -3
- package/dist/service/queryInspection.js.map +1 -1
- package/dist/service/references.d.ts +3 -2
- package/dist/service/references.js +9 -8
- package/dist/service/references.js.map +1 -1
- package/dist/service/rowEdit.d.ts +3 -0
- package/dist/service/rowEdit.js +36 -3
- package/dist/service/rowEdit.js.map +1 -1
- package/dist/service/types.d.ts +1 -1
- package/dist/utils/deadline.d.ts +2 -0
- package/dist/utils/deadline.js +18 -0
- package/dist/utils/deadline.js.map +1 -0
- package/dist/utils/guards.d.ts +2 -0
- package/dist/utils/guards.js +8 -0
- package/dist/utils/guards.js.map +1 -1
- package/dist/utils/query.js +5 -4
- package/dist/utils/query.js.map +1 -1
- package/frontend-vue/app/build/components/DataBrowserAccessBar.vue +88 -0
- package/frontend-vue/app/build/components/DataGridToolbar.vue +10 -5
- package/frontend-vue/app/build/components/FeatureLocked.vue +16 -0
- package/frontend-vue/app/build/components/QueryConsoleBoard.vue +601 -0
- package/frontend-vue/app/build/components/SchemaDiagramBoard.vue +691 -0
- package/frontend-vue/app/build/composables/registerDatabaseSwitcher.ts +16 -0
- package/frontend-vue/app/build/composables/reloadForSelection.ts +13 -0
- package/frontend-vue/app/build/composables/useDataBrowserTabs.ts +9 -0
- package/frontend-vue/app/build/composables/useDatabaseConnections.ts +164 -0
- package/frontend-vue/app/build/composables/useGridAccess.ts +25 -0
- package/frontend-vue/app/build/composables/useLockedPages.ts +53 -0
- package/frontend-vue/app/build/composables/useQueryRuntime.ts +4 -4
- package/frontend-vue/app/build/composables/useSelectionRecheck.ts +23 -0
- package/frontend-vue/app/build/data/assistantOnboarding.ts +12 -0
- package/frontend-vue/app/build/data/readOnlyReason.ts +30 -0
- package/frontend-vue/app/build/data/recentTables.ts +6 -0
- package/frontend-vue/app/build/data/staleDatabase.ts +58 -0
- package/frontend-vue/app/build/data/useStagedSave.ts +10 -1
- package/frontend-vue/app/components/DataBrowser.vue +9 -1
- package/frontend-vue/app/components/DataBrowserSidebar.vue +23 -13
- package/frontend-vue/app/components/DataGrid.vue +17 -6
- package/frontend-vue/app/components/DataGridCell.vue +5 -2
- package/frontend-vue/app/components/DatabaseSwitcher.vue +103 -0
- package/frontend-vue/app/components/QueryBuilderPanel.vue +4 -4
- package/frontend-vue/app/components/QueryConsole.vue +11 -592
- package/frontend-vue/app/components/QueryLibrary.vue +3 -3
- package/frontend-vue/app/components/QueryResultPanel.vue +5 -5
- package/frontend-vue/app/components/RowDrawer.vue +21 -14
- package/frontend-vue/app/components/SchemaDiagram.vue +10 -683
- package/frontend-vue/app/components/SchemasFilterBar.vue +3 -0
- package/frontend-vue/app/components/TableInspector.vue +8 -4
- package/frontend-vue/build/backend-boundary.ts +8 -3
- package/frontend-vue/dms.frontend.ts +2 -0
- package/frontend-vue/eslint.config.mjs +0 -1
- package/frontend-vue/i18n/locales/database-en-GB.json +31 -1
- package/frontend-vue/i18n/locales/database-fr-FR.json +31 -1
- package/frontend-vue/package.json +3 -3
- package/frontend-vue/pnpm-lock.yaml +14 -11
- package/frontend-vue/tests/accessBar.test.ts +196 -0
- package/frontend-vue/tests/backend-boundary.test.ts +15 -7
- package/frontend-vue/tests/databaseSwitcher.test.ts +339 -0
- package/frontend-vue/tests/editRequest.test.ts +146 -0
- package/frontend-vue/tests/externalBrowser.test.ts +193 -0
- package/frontend-vue/tests/fixtures/connections.ts +73 -0
- package/frontend-vue/tests/fixtures/serverRender.ts +135 -12
- package/frontend-vue/tests/lockedPages.test.ts +68 -0
- package/frontend-vue/tests/onDemandReads.test.ts +1 -1
- package/frontend-vue/tests/registration.test.ts +15 -1
- package/frontend-vue/tests/serverRender.test.ts +58 -4
- package/frontend-vue/vitest.config.ts +11 -1
- package/package.json +19 -15
- package/dist/service/schemaRegistry.d.ts +0 -2
- package/dist/service/schemaRegistry.js +0 -8
- package/dist/service/schemaRegistry.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { onKeyStroke, watchDebounced } from '@vueuse/core'
|
|
3
|
+
import { useDatabaseConnections } from '../build/composables/useDatabaseConnections'
|
|
3
4
|
import { useDatabaseSchemas } from '../build/composables/useDatabaseSchemas'
|
|
4
5
|
import {
|
|
5
6
|
EMPTY_FILTER_STATE,
|
|
@@ -34,6 +35,7 @@ const { t, n } = useI18n()
|
|
|
34
35
|
const route = useDmsRoute()
|
|
35
36
|
const router = useDmsRouter()
|
|
36
37
|
const { schemas, isSettled: schemasSettled } = useDatabaseSchemas()
|
|
38
|
+
const { lacks } = useDatabaseConnections()
|
|
37
39
|
const schemaIds = computed(() => schemas.value.map((schema) => schema.id))
|
|
38
40
|
const listing = useSchemasListing()
|
|
39
41
|
const state = listing.state
|
|
@@ -129,6 +131,7 @@ const count = computed(() => {
|
|
|
129
131
|
/>
|
|
130
132
|
|
|
131
133
|
<InstancePicker
|
|
134
|
+
v-if="!lacks('instances')"
|
|
132
135
|
:model-value="state.instance"
|
|
133
136
|
:schema="state.scope"
|
|
134
137
|
class="w-[calc(50%-0.25rem)] sm:w-48"
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
import { CROSS_INSTANCE_VALUE } from '../build/composables/useDataBrowserTabs'
|
|
30
30
|
import { ALL_INSTANCES_PARAM, tableLink } from '../build/utils/databaseLinks'
|
|
31
31
|
import { useTableSample } from '../build/composables/useTableSample'
|
|
32
|
+
import { useDatabaseConnections } from '../build/composables/useDatabaseConnections'
|
|
32
33
|
import DrawerTabs from './DrawerTabs.vue'
|
|
33
34
|
|
|
34
35
|
// The Schemas page's row drawer (D-07), also opened from the diagram: the
|
|
@@ -61,6 +62,7 @@ const NULLISH_KINDS = new Set<FieldDescriptor['kind']>([
|
|
|
61
62
|
const BROWSE_COUNT = '/api/database/browse/count'
|
|
62
63
|
|
|
63
64
|
const { t, n } = useI18n()
|
|
65
|
+
const { lacks } = useDatabaseConnections()
|
|
64
66
|
const { copy } = useClipboard()
|
|
65
67
|
const toast = useToast()
|
|
66
68
|
|
|
@@ -301,7 +303,7 @@ async function copyName() {
|
|
|
301
303
|
<div class="flex w-full min-w-0 flex-col gap-4">
|
|
302
304
|
<header class="grid grid-cols-[minmax(0,1fr)] gap-3">
|
|
303
305
|
<div class="flex min-w-0 flex-wrap items-center gap-2">
|
|
304
|
-
<
|
|
306
|
+
<DmsEyebrowLabel
|
|
305
307
|
class="min-w-0 truncate"
|
|
306
308
|
:label="t('dms_database.inspector.eyebrow', { schema: schemaId })"
|
|
307
309
|
/>
|
|
@@ -361,6 +363,7 @@ async function copyName() {
|
|
|
361
363
|
:label="t('dms_database.inspector.actions.browse')"
|
|
362
364
|
/>
|
|
363
365
|
<UButton
|
|
366
|
+
v-if="!lacks('queryConsole')"
|
|
364
367
|
:to="tableLink('query', address)"
|
|
365
368
|
@click="emit('success')"
|
|
366
369
|
icon="i-ph-code"
|
|
@@ -370,6 +373,7 @@ async function copyName() {
|
|
|
370
373
|
:label="t('dms_database.inspector.actions.query')"
|
|
371
374
|
/>
|
|
372
375
|
<UButton
|
|
376
|
+
v-if="!lacks('diagram')"
|
|
373
377
|
:to="tableLink('diagram', address)"
|
|
374
378
|
@click="emit('success')"
|
|
375
379
|
icon="i-ph-graph"
|
|
@@ -524,7 +528,7 @@ async function copyName() {
|
|
|
524
528
|
|
|
525
529
|
<div v-else-if="tab === 'relations'" class="grid gap-5">
|
|
526
530
|
<section class="grid gap-2">
|
|
527
|
-
<
|
|
531
|
+
<DmsEyebrowLabel
|
|
528
532
|
:label="
|
|
529
533
|
t('dms_database.inspector.relations.out', {
|
|
530
534
|
count: outgoing.length,
|
|
@@ -550,7 +554,7 @@ async function copyName() {
|
|
|
550
554
|
</p>
|
|
551
555
|
</section>
|
|
552
556
|
<section class="grid gap-2">
|
|
553
|
-
<
|
|
557
|
+
<DmsEyebrowLabel
|
|
554
558
|
:label="
|
|
555
559
|
t('dms_database.inspector.relations.in', {
|
|
556
560
|
count: incoming.length,
|
|
@@ -583,7 +587,7 @@ async function copyName() {
|
|
|
583
587
|
v-if="sampleTotal > 0"
|
|
584
588
|
class="flex min-w-0 items-center justify-between gap-2"
|
|
585
589
|
>
|
|
586
|
-
<
|
|
590
|
+
<DmsEyebrowLabel
|
|
587
591
|
class="min-w-0 truncate"
|
|
588
592
|
:label="
|
|
589
593
|
t('dms_database.inspector.sample.position', {
|
|
@@ -4,7 +4,7 @@ import type { DmsVitePluginEntry } from '#dms/frontend-build'
|
|
|
4
4
|
|
|
5
5
|
type VitePlugin = Extract<DmsVitePluginEntry, { name: string }>
|
|
6
6
|
|
|
7
|
-
const BACKEND_PACKAGE =
|
|
7
|
+
const BACKEND_PACKAGE = "@antelopejs/dms-database"
|
|
8
8
|
const BACKEND_SOURCE = 'src'
|
|
9
9
|
const QUERY_OR_HASH = /[?#].*$/
|
|
10
10
|
|
|
@@ -74,6 +74,11 @@ function backendSourceFile(id: string): string | undefined {
|
|
|
74
74
|
: undefined
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/** `path` with `/` separators, the form Vite gives an importer, so a boundary error names both paths alike on every OS. */
|
|
78
|
+
function forwardSlashes(path: string): string {
|
|
79
|
+
return path.split(sep).join('/')
|
|
80
|
+
}
|
|
81
|
+
|
|
77
82
|
/**
|
|
78
83
|
* Fails the build and the dev server when a module of the frontend resolves to
|
|
79
84
|
* a file under the `src` of the backend package: the browser reaches the
|
|
@@ -113,9 +118,9 @@ function boundaryCheck(): VitePlugin {
|
|
|
113
118
|
const from =
|
|
114
119
|
importer === undefined
|
|
115
120
|
? 'an entry point'
|
|
116
|
-
: importer.replace(QUERY_OR_HASH, '')
|
|
121
|
+
: forwardSlashes(importer.replace(QUERY_OR_HASH, ''))
|
|
117
122
|
return this.error(
|
|
118
|
-
`Backend boundary: ${from} imports ${file}, which is under the src of ${BACKEND_PACKAGE}. The frontend reaches the backend only through its HTTP interface.`,
|
|
123
|
+
`Backend boundary: ${from} imports ${forwardSlashes(file)}, which is under the src of ${BACKEND_PACKAGE}. The frontend reaches the backend only through its HTTP interface.`,
|
|
119
124
|
)
|
|
120
125
|
},
|
|
121
126
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineAsyncComponent, type Component } from 'vue'
|
|
2
2
|
import type { DmsFrontendModule } from '#dms/frontend-module'
|
|
3
|
+
import { registerDatabaseSwitcher } from './app/build/composables/registerDatabaseSwitcher'
|
|
3
4
|
|
|
4
5
|
interface VueModule {
|
|
5
6
|
default: Component
|
|
@@ -23,6 +24,7 @@ const frontendModule: DmsFrontendModule = {
|
|
|
23
24
|
defineAsyncComponent(async () => (await loader()).default),
|
|
24
25
|
)
|
|
25
26
|
}
|
|
27
|
+
sdk.registerPlugin(registerDatabaseSwitcher)
|
|
26
28
|
},
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -217,7 +217,9 @@
|
|
|
217
217
|
"rows_gone": "{count} row no longer exists: its changes were dropped. | {count} rows no longer exist: their changes were dropped.",
|
|
218
218
|
"not_written": "{count} change wasn't written and stays staged ({error}). | {count} changes weren't written and stay staged ({error}).",
|
|
219
219
|
"undo_partial": "{count} change couldn't be undone | {count} changes couldn't be undone",
|
|
220
|
-
"rows_missing": "{count} row no longer exists. | {count} rows no longer exist."
|
|
220
|
+
"rows_missing": "{count} row no longer exists. | {count} rows no longer exist.",
|
|
221
|
+
"database_changed": "The selected database changed in another tab: reload the page.",
|
|
222
|
+
"read_only_access": "Access to {connection} is read only."
|
|
221
223
|
},
|
|
222
224
|
"row": {
|
|
223
225
|
"position": "Row {index} of {total}",
|
|
@@ -243,6 +245,34 @@
|
|
|
243
245
|
"help": "An object or a list. Type null to empty the cell."
|
|
244
246
|
}
|
|
245
247
|
},
|
|
248
|
+
"connections": {
|
|
249
|
+
"own": "Project database",
|
|
250
|
+
"external": "External",
|
|
251
|
+
"engine_unknown": "Unknown engine",
|
|
252
|
+
"switcher": {
|
|
253
|
+
"label": "Database",
|
|
254
|
+
"menu": "Choose the database to browse",
|
|
255
|
+
"failed": "The database could not be switched.",
|
|
256
|
+
"connect": "Connect a database"
|
|
257
|
+
},
|
|
258
|
+
"access": {
|
|
259
|
+
"read": "Access to {name}: Read only",
|
|
260
|
+
"read_write": "Access to {name}: Read & write",
|
|
261
|
+
"toggle": "Allow changes to {name}",
|
|
262
|
+
"account_read_only": "This account can only read. Use an account with write access to allow changes.",
|
|
263
|
+
"account_unverified": "This account's write access could not be checked.",
|
|
264
|
+
"failed": "The access to the database could not be changed.",
|
|
265
|
+
"confirm": {
|
|
266
|
+
"title": "Allow changes to {name}?",
|
|
267
|
+
"description": "{name} is your customer's live database. Changes you save are written to it at once, and the DMS cannot undo them.",
|
|
268
|
+
"action": "Allow changes",
|
|
269
|
+
"cancel": "Keep read only"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"locked": {
|
|
273
|
+
"reason": "Not available on an external database"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
246
276
|
"diagram": {
|
|
247
277
|
"title": "Diagram",
|
|
248
278
|
"description": "Tables and relations of a schema. Drag tables to arrange them; the layout is saved for the whole team.",
|
|
@@ -217,7 +217,9 @@
|
|
|
217
217
|
"rows_gone": "{count} ligne n'existe plus : ses modifications ont été abandonnées. | {count} lignes n'existent plus : leurs modifications ont été abandonnées.",
|
|
218
218
|
"not_written": "{count} modification n'a pas été écrite et reste préparée ({error}). | {count} modifications n'ont pas été écrites et restent préparées ({error}).",
|
|
219
219
|
"undo_partial": "{count} modification n'a pas pu être annulée | {count} modifications n'ont pas pu être annulées",
|
|
220
|
-
"rows_missing": "{count} ligne n'existe plus. | {count} lignes n'existent plus."
|
|
220
|
+
"rows_missing": "{count} ligne n'existe plus. | {count} lignes n'existent plus.",
|
|
221
|
+
"database_changed": "La base sélectionnée a changé dans un autre onglet : rechargez la page.",
|
|
222
|
+
"read_only_access": "L'accès à {connection} est en lecture seule."
|
|
221
223
|
},
|
|
222
224
|
"row": {
|
|
223
225
|
"position": "Ligne {index} sur {total}",
|
|
@@ -243,6 +245,34 @@
|
|
|
243
245
|
"help": "Un objet ou une liste. Tapez null pour vider la cellule."
|
|
244
246
|
}
|
|
245
247
|
},
|
|
248
|
+
"connections": {
|
|
249
|
+
"own": "Base du projet",
|
|
250
|
+
"external": "Externe",
|
|
251
|
+
"engine_unknown": "Moteur inconnu",
|
|
252
|
+
"switcher": {
|
|
253
|
+
"label": "Base de données",
|
|
254
|
+
"menu": "Choisir la base à parcourir",
|
|
255
|
+
"failed": "La base n'a pas pu être changée.",
|
|
256
|
+
"connect": "Connecter une base"
|
|
257
|
+
},
|
|
258
|
+
"access": {
|
|
259
|
+
"read": "Accès à {name} : lecture seule",
|
|
260
|
+
"read_write": "Accès à {name} : lecture et écriture",
|
|
261
|
+
"toggle": "Autoriser les modifications de {name}",
|
|
262
|
+
"account_read_only": "Ce compte peut seulement lire. Utilisez un compte avec accès en écriture pour autoriser les modifications.",
|
|
263
|
+
"account_unverified": "Les droits d'écriture de ce compte n'ont pas pu être vérifiés.",
|
|
264
|
+
"failed": "L'accès à la base n'a pas pu être modifié.",
|
|
265
|
+
"confirm": {
|
|
266
|
+
"title": "Autoriser les modifications de {name} ?",
|
|
267
|
+
"description": "{name} est la base en production de votre client. Les modifications enregistrées y sont écrites aussitôt, et le DMS ne peut pas les annuler.",
|
|
268
|
+
"action": "Autoriser les modifications",
|
|
269
|
+
"cancel": "Rester en lecture seule"
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"locked": {
|
|
273
|
+
"reason": "Indisponible sur une base externe"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
246
276
|
"diagram": {
|
|
247
277
|
"title": "Diagramme",
|
|
248
278
|
"description": "Les tables d'un schéma et leurs relations. Déplacez les tables pour les arranger ; la disposition est enregistrée pour toute l'équipe.",
|
|
@@ -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.
|
|
9
|
+
"@antelopejs/dms-frontend": ">=0.11.1 <0.12.0"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"dev": "pnpm --dir ../playground frontend:dev",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@antelopejs/interface-core": ">=0.
|
|
22
|
-
"@antelopejs/interface-database": ">=0.
|
|
21
|
+
"@antelopejs/interface-core": ">=0.5.1 <0.6.0",
|
|
22
|
+
"@antelopejs/interface-database": ">=0.4.0 <0.5.0",
|
|
23
23
|
"@codemirror/autocomplete": "^6.18.6",
|
|
24
24
|
"@codemirror/commands": "^6.8.1",
|
|
25
25
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
@@ -9,11 +9,11 @@ importers:
|
|
|
9
9
|
.:
|
|
10
10
|
dependencies:
|
|
11
11
|
'@antelopejs/interface-core':
|
|
12
|
-
specifier: '>=0.
|
|
13
|
-
version: 0.
|
|
12
|
+
specifier: '>=0.5.1 <0.6.0'
|
|
13
|
+
version: 0.5.1
|
|
14
14
|
'@antelopejs/interface-database':
|
|
15
|
-
specifier: '>=0.
|
|
16
|
-
version: 0.
|
|
15
|
+
specifier: '>=0.4.0 <0.5.0'
|
|
16
|
+
version: 0.4.0(@antelopejs/interface-core@0.5.1)
|
|
17
17
|
'@codemirror/autocomplete':
|
|
18
18
|
specifier: ^6.18.6
|
|
19
19
|
version: 6.20.3
|
|
@@ -88,11 +88,11 @@ packages:
|
|
|
88
88
|
resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}
|
|
89
89
|
engines: {node: '>=10'}
|
|
90
90
|
|
|
91
|
-
'@antelopejs/interface-core@0.
|
|
92
|
-
resolution: {integrity: sha512-
|
|
91
|
+
'@antelopejs/interface-core@0.5.1':
|
|
92
|
+
resolution: {integrity: sha512-ON/7TYA1yyT8UznzKi6vnwyjRU3byNE0OcFXBmf8dE/dqp8hKjeWHVyA2EUPOngmEimCLw4idZqOS5DJqMJx3g==}
|
|
93
93
|
|
|
94
|
-
'@antelopejs/interface-database@0.
|
|
95
|
-
resolution: {integrity: sha512-
|
|
94
|
+
'@antelopejs/interface-database@0.4.0':
|
|
95
|
+
resolution: {integrity: sha512-cdVGd0qdHwkS3PHdbV9IJUyL3OoGjnmXoVbXdHPNmbwzmjUDkZQHFN2Y3b58SGsH11k3nS1EJLq0sTbKVhaKdQ==}
|
|
96
96
|
peerDependencies:
|
|
97
97
|
'@antelopejs/interface-core': '>=0.2.4 <1.0.0'
|
|
98
98
|
|
|
@@ -3111,17 +3111,20 @@ packages:
|
|
|
3111
3111
|
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
|
|
3112
3112
|
engines: {node: '>=10'}
|
|
3113
3113
|
|
|
3114
|
+
ignoredOptionalDependencies:
|
|
3115
|
+
- playwright-core
|
|
3116
|
+
|
|
3114
3117
|
snapshots:
|
|
3115
3118
|
|
|
3116
3119
|
'@alloc/quick-lru@5.2.0': {}
|
|
3117
3120
|
|
|
3118
|
-
'@antelopejs/interface-core@0.
|
|
3121
|
+
'@antelopejs/interface-core@0.5.1':
|
|
3119
3122
|
dependencies:
|
|
3120
3123
|
reflect-metadata: 0.2.2
|
|
3121
3124
|
|
|
3122
|
-
'@antelopejs/interface-database@0.
|
|
3125
|
+
'@antelopejs/interface-database@0.4.0(@antelopejs/interface-core@0.5.1)':
|
|
3123
3126
|
dependencies:
|
|
3124
|
-
'@antelopejs/interface-core': 0.
|
|
3127
|
+
'@antelopejs/interface-core': 0.5.1
|
|
3125
3128
|
|
|
3126
3129
|
'@antfu/install-pkg@2.0.1':
|
|
3127
3130
|
dependencies:
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
answerConfirmations,
|
|
4
|
+
browserMount,
|
|
5
|
+
confirmations,
|
|
6
|
+
} from './fixtures/serverRender'
|
|
7
|
+
import {
|
|
8
|
+
OWN,
|
|
9
|
+
WAREHOUSE,
|
|
10
|
+
connectionWrites,
|
|
11
|
+
connectionsBackend,
|
|
12
|
+
connectionsState,
|
|
13
|
+
} from './fixtures/connections'
|
|
14
|
+
import type { ConnectionsState } from '../app/build/composables/useDatabaseConnections'
|
|
15
|
+
import DataBrowserAccessBar from '../app/build/components/DataBrowserAccessBar.vue'
|
|
16
|
+
|
|
17
|
+
const SWITCH = (props: Record<string, unknown>) =>
|
|
18
|
+
props['data-stub'] === 'DmsInputSwitch'
|
|
19
|
+
|
|
20
|
+
async function mountBar(state: ConnectionsState, answer?: () => unknown) {
|
|
21
|
+
const page = browserMount(
|
|
22
|
+
DataBrowserAccessBar,
|
|
23
|
+
connectionsBackend(state, { answer }),
|
|
24
|
+
)
|
|
25
|
+
await page.shown
|
|
26
|
+
await vi.waitFor(() => expect(page.reads).not.toHaveLength(0))
|
|
27
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
28
|
+
return page
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type Page = Awaited<ReturnType<typeof mountBar>>
|
|
32
|
+
|
|
33
|
+
function toggle(page: Page, allowed: boolean): void {
|
|
34
|
+
const update = page.find(SWITCH)?.['onUpdate:modelValue']
|
|
35
|
+
expect(update).toBeTypeOf('function')
|
|
36
|
+
if (typeof update === 'function') update(allowed)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('access bar: what it says', () => {
|
|
40
|
+
it('says read only or read and write for the external database, by its name', async () => {
|
|
41
|
+
const readOnly = await mountBar(connectionsState(WAREHOUSE))
|
|
42
|
+
expect(readOnly.text()).toContain(
|
|
43
|
+
'dms_database.connections.access.read Warehouse',
|
|
44
|
+
)
|
|
45
|
+
const readWrite = await mountBar(
|
|
46
|
+
connectionsState({ ...WAREHOUSE, access: 'read-write' }),
|
|
47
|
+
)
|
|
48
|
+
expect(readWrite.text()).toContain(
|
|
49
|
+
'dms_database.connections.access.read_write Warehouse',
|
|
50
|
+
)
|
|
51
|
+
expect(readWrite.text()).not.toContain(
|
|
52
|
+
'dms_database.connections.access.read Warehouse',
|
|
53
|
+
)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('is absent on the project database, which an implementation showing it for every connection gets wrong', async () => {
|
|
57
|
+
const page = await mountBar(connectionsState(OWN))
|
|
58
|
+
expect(page.text()).not.toContain('data-access-bar')
|
|
59
|
+
expect(page.find(SWITCH)).toBeUndefined()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('shows the access as text only outside development, with no switch', async () => {
|
|
63
|
+
const page = await mountBar(
|
|
64
|
+
connectionsState(WAREHOUSE, { accessEditable: false }),
|
|
65
|
+
)
|
|
66
|
+
expect(page.text()).toContain(
|
|
67
|
+
'dms_database.connections.access.read Warehouse',
|
|
68
|
+
)
|
|
69
|
+
expect(page.find(SWITCH)).toBeUndefined()
|
|
70
|
+
expect(page.text()).not.toContain('account_read_only')
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('access bar: an account that cannot write', () => {
|
|
75
|
+
it.each([false, null])(
|
|
76
|
+
'locks the switch on read while canWrite is %s, which an implementation that leaves it free gets wrong',
|
|
77
|
+
async (canWrite) => {
|
|
78
|
+
const page = await mountBar(connectionsState({ ...WAREHOUSE, canWrite }))
|
|
79
|
+
expect(page.find(SWITCH)).toMatchObject({ disabled: true })
|
|
80
|
+
expect(page.text()).toContain('name="i-ph-lock"')
|
|
81
|
+
},
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
it.each([false, null])(
|
|
85
|
+
'leaves the switch free on read and write while canWrite is %s, so it can go back to read: an implementation locking on canWrite alone traps the access',
|
|
86
|
+
async (canWrite) => {
|
|
87
|
+
const page = await mountBar(
|
|
88
|
+
connectionsState({ ...WAREHOUSE, access: 'read-write', canWrite }, {}),
|
|
89
|
+
() => connectionsState(WAREHOUSE),
|
|
90
|
+
)
|
|
91
|
+
expect(page.find(SWITCH)).toMatchObject({ disabled: false })
|
|
92
|
+
toggle(page, false)
|
|
93
|
+
await vi.waitFor(() =>
|
|
94
|
+
expect(connectionWrites(page.reads)).toEqual([
|
|
95
|
+
{
|
|
96
|
+
method: 'PUT',
|
|
97
|
+
url: '/api/database/connections/warehouse/access',
|
|
98
|
+
body: { access: 'read' },
|
|
99
|
+
},
|
|
100
|
+
]),
|
|
101
|
+
)
|
|
102
|
+
},
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
it('tells an account that cannot write from one the catalog did not answer for, which an implementation with one text for both gets wrong', async () => {
|
|
106
|
+
const refused = await mountBar(
|
|
107
|
+
connectionsState({ ...WAREHOUSE, canWrite: false }),
|
|
108
|
+
)
|
|
109
|
+
const unchecked = await mountBar(
|
|
110
|
+
connectionsState({ ...WAREHOUSE, canWrite: null }),
|
|
111
|
+
)
|
|
112
|
+
expect(refused.text()).toContain(
|
|
113
|
+
'dms_database.connections.access.account_read_only',
|
|
114
|
+
)
|
|
115
|
+
expect(refused.text()).not.toContain('account_unverified')
|
|
116
|
+
expect(unchecked.text()).toContain(
|
|
117
|
+
'dms_database.connections.access.account_unverified',
|
|
118
|
+
)
|
|
119
|
+
expect(unchecked.text()).not.toContain('account_read_only')
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('leaves the switch free, with no account message, when the account can write', async () => {
|
|
123
|
+
const page = await mountBar(connectionsState(WAREHOUSE))
|
|
124
|
+
expect(page.find(SWITCH)).toMatchObject({ disabled: false })
|
|
125
|
+
expect(page.text()).not.toContain('account_read_only')
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
describe('access bar: changing the access', () => {
|
|
130
|
+
it('asks before it allows writes, and writes nothing when the user declines', async () => {
|
|
131
|
+
answerConfirmations(false)
|
|
132
|
+
const page = await mountBar(connectionsState(WAREHOUSE))
|
|
133
|
+
toggle(page, true)
|
|
134
|
+
await vi.waitFor(() => expect(confirmations).toHaveLength(1))
|
|
135
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
136
|
+
expect(connectionWrites(page.reads)).toEqual([])
|
|
137
|
+
expect(confirmations[0]).toMatchObject({
|
|
138
|
+
color: 'warning',
|
|
139
|
+
description:
|
|
140
|
+
'dms_database.connections.access.confirm.description Warehouse',
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('allows writes once the user confirms, and then shows read and write from the answer', async () => {
|
|
145
|
+
answerConfirmations(true)
|
|
146
|
+
const written = connectionsState({ ...WAREHOUSE, access: 'read-write' })
|
|
147
|
+
const page = await mountBar(connectionsState(WAREHOUSE), () => written)
|
|
148
|
+
toggle(page, true)
|
|
149
|
+
await vi.waitFor(() =>
|
|
150
|
+
expect(page.text()).toContain(
|
|
151
|
+
'dms_database.connections.access.read_write Warehouse',
|
|
152
|
+
),
|
|
153
|
+
)
|
|
154
|
+
expect(confirmations).toHaveLength(1)
|
|
155
|
+
expect(connectionWrites(page.reads)).toEqual([
|
|
156
|
+
{
|
|
157
|
+
method: 'PUT',
|
|
158
|
+
url: '/api/database/connections/warehouse/access',
|
|
159
|
+
body: { access: 'read-write' },
|
|
160
|
+
},
|
|
161
|
+
])
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('goes back to read without asking', async () => {
|
|
165
|
+
answerConfirmations(false)
|
|
166
|
+
const page = await mountBar(
|
|
167
|
+
connectionsState({ ...WAREHOUSE, access: 'read-write' }),
|
|
168
|
+
() => connectionsState(WAREHOUSE),
|
|
169
|
+
)
|
|
170
|
+
toggle(page, false)
|
|
171
|
+
await vi.waitFor(() =>
|
|
172
|
+
expect(connectionWrites(page.reads)).toEqual([
|
|
173
|
+
{
|
|
174
|
+
method: 'PUT',
|
|
175
|
+
url: '/api/database/connections/warehouse/access',
|
|
176
|
+
body: { access: 'read' },
|
|
177
|
+
},
|
|
178
|
+
]),
|
|
179
|
+
)
|
|
180
|
+
expect(confirmations).toEqual([])
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('keeps the access it showed when the server refuses the change', async () => {
|
|
184
|
+
answerConfirmations(true)
|
|
185
|
+
const page = await mountBar(connectionsState(WAREHOUSE), () => {
|
|
186
|
+
throw new Error('This account can only read.')
|
|
187
|
+
})
|
|
188
|
+
toggle(page, true)
|
|
189
|
+
await vi.waitFor(() => expect(connectionWrites(page.reads)).toHaveLength(1))
|
|
190
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
191
|
+
expect(page.text()).toContain(
|
|
192
|
+
'dms_database.connections.access.read Warehouse',
|
|
193
|
+
)
|
|
194
|
+
expect(page.errors).toEqual([])
|
|
195
|
+
})
|
|
196
|
+
})
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mkdirSync,
|
|
3
3
|
mkdtempSync,
|
|
4
|
+
realpathSync,
|
|
4
5
|
rmSync,
|
|
5
6
|
symlinkSync,
|
|
6
7
|
writeFileSync,
|
|
7
8
|
} from 'node:fs'
|
|
8
9
|
import { tmpdir } from 'node:os'
|
|
9
10
|
import { join } from 'node:path'
|
|
10
|
-
import { build, type Plugin } from 'vite'
|
|
11
|
+
import { build, normalizePath, type Plugin } from 'vite'
|
|
11
12
|
import { afterEach, beforeEach, expect, it } from 'vitest'
|
|
12
13
|
import { backendBoundary } from '../build/backend-boundary.ts'
|
|
13
14
|
|
|
@@ -15,7 +16,9 @@ const BOUNDARY = 'Backend boundary: '
|
|
|
15
16
|
|
|
16
17
|
let root: string
|
|
17
18
|
beforeEach(() => {
|
|
18
|
-
root =
|
|
19
|
+
root = realpathSync.native(
|
|
20
|
+
mkdtempSync(join(tmpdir(), 'dms-database-boundary-')),
|
|
21
|
+
)
|
|
19
22
|
mkdirSync(join(root, 'backend/src'), { recursive: true })
|
|
20
23
|
mkdirSync(join(root, 'backend/dist'), { recursive: true })
|
|
21
24
|
mkdirSync(join(root, 'frontend'), { recursive: true })
|
|
@@ -28,6 +31,11 @@ beforeEach(() => {
|
|
|
28
31
|
})
|
|
29
32
|
afterEach(() => rmSync(root, { recursive: true, force: true }))
|
|
30
33
|
|
|
34
|
+
/** A file under the root as the plugin names it, with Vite's `/` separators. */
|
|
35
|
+
function reported(path: string) {
|
|
36
|
+
return normalizePath(join(root, path))
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
function bundle(entry: string, extra: Plugin[] = []) {
|
|
32
40
|
writeFileSync(join(root, 'frontend/entry.ts'), entry)
|
|
33
41
|
return build({
|
|
@@ -47,8 +55,8 @@ it('fails on an import of the backend source and names both files', async () =>
|
|
|
47
55
|
'import { api } from "../backend/src/api"\nexport default api\n',
|
|
48
56
|
)
|
|
49
57
|
await expect(failing).rejects.toThrow(BOUNDARY)
|
|
50
|
-
await expect(failing).rejects.toThrow(
|
|
51
|
-
await expect(failing).rejects.toThrow(
|
|
58
|
+
await expect(failing).rejects.toThrow(reported('frontend/entry.ts'))
|
|
59
|
+
await expect(failing).rejects.toThrow(reported('backend/src/api.ts'))
|
|
52
60
|
})
|
|
53
61
|
|
|
54
62
|
it('fails on an import nested below the backend source', async () => {
|
|
@@ -61,7 +69,7 @@ it('fails on an import nested below the backend source', async () => {
|
|
|
61
69
|
'import { deep } from "../backend/src/x/y/deep"\nexport default deep\n',
|
|
62
70
|
)
|
|
63
71
|
await expect(failing).rejects.toThrow(BOUNDARY)
|
|
64
|
-
await expect(failing).rejects.toThrow(
|
|
72
|
+
await expect(failing).rejects.toThrow(reported('backend/src/x/y/deep.ts'))
|
|
65
73
|
})
|
|
66
74
|
|
|
67
75
|
it('accepts a backend directory that only starts with src', async () => {
|
|
@@ -110,7 +118,7 @@ it('follows a symlink the resolver returns to the backend source', async () => {
|
|
|
110
118
|
resolvingTo(() => join(root, 'frontend/linked.ts')),
|
|
111
119
|
])
|
|
112
120
|
await expect(failing).rejects.toThrow(BOUNDARY)
|
|
113
|
-
await expect(failing).rejects.toThrow(
|
|
121
|
+
await expect(failing).rejects.toThrow(reported('backend/src/api.ts'))
|
|
114
122
|
})
|
|
115
123
|
|
|
116
124
|
it('sees through a query on the resolved id', async () => {
|
|
@@ -118,7 +126,7 @@ it('sees through a query on the resolved id', async () => {
|
|
|
118
126
|
resolvingTo(() => `${join(root, 'backend/src/api.ts')}?raw`),
|
|
119
127
|
])
|
|
120
128
|
await expect(failing).rejects.toThrow(BOUNDARY)
|
|
121
|
-
await expect(failing).rejects.toThrow(
|
|
129
|
+
await expect(failing).rejects.toThrow(reported('backend/src/api.ts'))
|
|
122
130
|
})
|
|
123
131
|
|
|
124
132
|
it('lets the owning package decide, not the directory name', async () => {
|